SlideShare a Scribd company logo
1 of 34
Device (dis)Orientation?

                Luz Caballero
                @gerbille
• What is it?
• Some math you need to know
• Code
• Support and implementations
• Tips and tricks
• deviceorientation
• devicemotion
• compassneedscalibration
static / one off                                     dynamic / interactive


  * image sources: http://mygadgetnews.com/tech/apple-looking-to-radically-improve-maps-and-location-services-in-ios-5
                                                               http://www.sub5zero.com/top-10-racing-games-iphone/
deviceorientation
Code at: https://github.com/luzc/wiimote
QuickTime™ and a
           decompressor
 are needed to see this picture.




(back up plan!)
The math
Tait-Bryan angles
QuickTime™ and a
        GIF decompressor
are needed to see this picture.
If you want to apply a rotation:


 V = R(gamma, y’’).R(beta, x’).R(alpha, z).Vo

 V=                                             .Vo




           3rd            2nd            1st
alpha/gamma singularity
Disoriented much?
The code
server.js
       α, β, ɣ               α, β, ɣ

remote.js                         model.js
remote.js:




    var ws = new WebSocket('ws://10.112.0.139:8080/');
    //listen to device orientation
    window.addEventListener('deviceorientation', function(e) {
      if (ws.opened) {
        ws.send(JSON.stringify({
          alpha: e.alpha,
          beta: e.beta,
          gamma: e.gamma
        }));
      }
    });
model.js:




 window.addEventListener('DOMContentLoaded', function init() {
   //connect to server using websockets
   var ws = new WebSocket('ws://10.112.0.139:8080/');
   ws.onopen = function() {
     ws.onmessage = function(e) {
        var data = JSON.parse(e.data),
          avalue = data.alpha / 180 * Math.PI,
          bvalue = data.beta / 180 * Math.PI,
          gvalue = data.gamma / 180 * Math.PI;
          teapot.rotation.set(gvalue, avalue, -bvalue);
       };
    };
 });
Support
luzc.github.com/webtests/   • orientation
                            • compass
                            • motion
Tested running
                                                  ↑N                  ↑up                ↑up
luzc.github.com/webtests/orientation in a
Samsung Galaxy 2 and an iPhone (iOS6), on   α                     β                  ɣ
February 18, 2013




                                                       270                  0                  0
                                                360/0___|___180       -90___|___90   -90/270___|___90
   Chrome for Android
                                                         |                  |                   |
                                                        90                  0                 180
                                                     360/0                   0                 0
                                                 270___|___90         -90___|___90       -90___|___90
    Firefox for Android
                                                       |                     |                 |
                                                      180                -180/180              0
                                                     0/360                   0                 0
      Opera Mobile for                            90___|___270        -90___|___90       -90___|___90
         Android                                       |                     |                 |
                                                      180                -180/180              0
                                                     0/360                   0                 0
                                                  90___|___270        -90___|___90       -90___|___90
        Safari for iOS6
                                                       |                     |                  |
                                                      180                    0              -180/180
                                                     0/360                   0                 0
          Specification                           90___|___270        -90___|___90       -90___|___90
                                                       |                     |                 |
                                                      180                -180/180              0
Portrait vs. landscape
       matters!
Holding your device THE RIGTH WAY™




How FF thinks you should hold   How Opera (and Chrome) think
   your landscape device        you should hold your landscape
                                            device
BYO Calibration!!
You may want some buffering

https://github.com/richtr/Marine-Compass
devicemotion
• rotationRate
• acceleration
• accelerationIncludingGravity
• interval
run luzc.github.com/webtests/motion
in a Samsung Galaxy Tab 2 and iOS6


• acceleration (Safari)
• accelerationIncludingGravity (Safari, Opera, FF)
• rotationRate (Safari)
• interval (Opera, Safari, FF)
window.addEventListener('devicemotion', function(e)
{      if(e.acceleration){         //e.acceleration.x
       //e.acceleration.y
       //e.acceleration.z       }
       if(e.accelerationIncludingGravity)
       {//e.accelerationIncludingGravity.x
//e.accelerationIncludingGravity.y
       //e.accelerationIncludingGravity.z        }
       if(e.rotationRate){         //e.rotationRate.alpha
       //e.rotationRate.beta
       //e.rotationRate.gamma        }      if(e.interval){
       //e.interval       }    });
}    });
       }     });
       }     });
}    });
Things to remember:

   •   Angular position, angular speed and acceleration
   •   Intrinsic axes of rotation
   •   Rotations have to be applied *in order*
   •   Singularity in alpha/gamma
   •   3D libraries / languages can make your life easier
   •   Browser support but different implementations
   •   BYO calibration
   •   Portrait/landscape matters
   •   You may want some buffering
   •   Device motion has only partial support
That’s all :)


 Thanks!!

                Luz Caballero
                @gerbille
                github.com/luzc

More Related Content

Similar to Device dis(orientation)?

Fake it 'til you make it
Fake it 'til you make itFake it 'til you make it
Fake it 'til you make itJonathan Snook
 
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25Ruby Meditation
 
Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020Matt Raible
 
Beauty Treatment for your Android Application
Beauty Treatment for your Android ApplicationBeauty Treatment for your Android Application
Beauty Treatment for your Android ApplicationCodemotion
 
Agados biz. introductio
Agados biz. introductioAgados biz. introductio
Agados biz. introductioYongkyoo Park
 
[Azure Council Experts (ACE) 第6回定例会] Microsoft Azureアップデート情報 (2014/06/18-2014...
[Azure Council Experts (ACE) 第6回定例会] Microsoft Azureアップデート情報 (2014/06/18-2014...[Azure Council Experts (ACE) 第6回定例会] Microsoft Azureアップデート情報 (2014/06/18-2014...
[Azure Council Experts (ACE) 第6回定例会] Microsoft Azureアップデート情報 (2014/06/18-2014...Naoki (Neo) SATO
 
Ease into HTML5 and CSS3
Ease into HTML5 and CSS3Ease into HTML5 and CSS3
Ease into HTML5 and CSS3Brian Moon
 
Designing for The Modern Web
Designing for The Modern WebDesigning for The Modern Web
Designing for The Modern WebSara Cannon
 
Make your animations perform well
Make your animations perform wellMake your animations perform well
Make your animations perform wellAnna Migas
 
Responsive design: techniques and tricks to prepare your websites for the mul...
Responsive design: techniques and tricks to prepare your websites for the mul...Responsive design: techniques and tricks to prepare your websites for the mul...
Responsive design: techniques and tricks to prepare your websites for the mul...Andreas Bovens
 
Feature Extraction for Predictive LTV Modeling using Hadoop, Hive, and Cascad...
Feature Extraction for Predictive LTV Modeling using Hadoop, Hive, and Cascad...Feature Extraction for Predictive LTV Modeling using Hadoop, Hive, and Cascad...
Feature Extraction for Predictive LTV Modeling using Hadoop, Hive, and Cascad...Kontagent
 
Make web Magical with framer-motion
Make web Magical with framer-motionMake web Magical with framer-motion
Make web Magical with framer-motionAbderraouf GATTAL
 
UIWebViewでつくるUI
UIWebViewでつくるUIUIWebViewでつくるUI
UIWebViewでつくるUIcocopon
 
How to create 360 Image/panorama & share with WebVR?
How to create  360 Image/panorama & share with WebVR?How to create  360 Image/panorama & share with WebVR?
How to create 360 Image/panorama & share with WebVR?Fred Lin
 
Swiftのこれまでの動向のまとめと 今後のさらなる発展の期待 - iOSDC 2016
Swiftのこれまでの動向のまとめと 今後のさらなる発展の期待 - iOSDC 2016Swiftのこれまでの動向のまとめと 今後のさらなる発展の期待 - iOSDC 2016
Swiftのこれまでの動向のまとめと 今後のさらなる発展の期待 - iOSDC 2016将之 小野
 
Fearless From Monolith to Serverless with Dynatrace
Fearless From Monolith to Serverless with DynatraceFearless From Monolith to Serverless with Dynatrace
Fearless From Monolith to Serverless with DynatraceAmazon Web Services
 
ITT 2015 - Vincent Garrigues - Continuous Integration at SoundCloud
ITT 2015 - Vincent Garrigues - Continuous Integration at SoundCloudITT 2015 - Vincent Garrigues - Continuous Integration at SoundCloud
ITT 2015 - Vincent Garrigues - Continuous Integration at SoundCloudIstanbul Tech Talks
 
Make Your Testing Groovy
Make Your Testing GroovyMake Your Testing Groovy
Make Your Testing GroovyPaul King
 

Similar to Device dis(orientation)? (20)

Fake it 'til you make it
Fake it 'til you make itFake it 'til you make it
Fake it 'til you make it
 
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
 
Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020
 
Beauty Treatment for your Android Application
Beauty Treatment for your Android ApplicationBeauty Treatment for your Android Application
Beauty Treatment for your Android Application
 
Agados biz. introductio
Agados biz. introductioAgados biz. introductio
Agados biz. introductio
 
Web app
Web appWeb app
Web app
 
Web app
Web appWeb app
Web app
 
[Azure Council Experts (ACE) 第6回定例会] Microsoft Azureアップデート情報 (2014/06/18-2014...
[Azure Council Experts (ACE) 第6回定例会] Microsoft Azureアップデート情報 (2014/06/18-2014...[Azure Council Experts (ACE) 第6回定例会] Microsoft Azureアップデート情報 (2014/06/18-2014...
[Azure Council Experts (ACE) 第6回定例会] Microsoft Azureアップデート情報 (2014/06/18-2014...
 
Ease into HTML5 and CSS3
Ease into HTML5 and CSS3Ease into HTML5 and CSS3
Ease into HTML5 and CSS3
 
Designing for The Modern Web
Designing for The Modern WebDesigning for The Modern Web
Designing for The Modern Web
 
Make your animations perform well
Make your animations perform wellMake your animations perform well
Make your animations perform well
 
Responsive design: techniques and tricks to prepare your websites for the mul...
Responsive design: techniques and tricks to prepare your websites for the mul...Responsive design: techniques and tricks to prepare your websites for the mul...
Responsive design: techniques and tricks to prepare your websites for the mul...
 
Feature Extraction for Predictive LTV Modeling using Hadoop, Hive, and Cascad...
Feature Extraction for Predictive LTV Modeling using Hadoop, Hive, and Cascad...Feature Extraction for Predictive LTV Modeling using Hadoop, Hive, and Cascad...
Feature Extraction for Predictive LTV Modeling using Hadoop, Hive, and Cascad...
 
Make web Magical with framer-motion
Make web Magical with framer-motionMake web Magical with framer-motion
Make web Magical with framer-motion
 
UIWebViewでつくるUI
UIWebViewでつくるUIUIWebViewでつくるUI
UIWebViewでつくるUI
 
How to create 360 Image/panorama & share with WebVR?
How to create  360 Image/panorama & share with WebVR?How to create  360 Image/panorama & share with WebVR?
How to create 360 Image/panorama & share with WebVR?
 
Swiftのこれまでの動向のまとめと 今後のさらなる発展の期待 - iOSDC 2016
Swiftのこれまでの動向のまとめと 今後のさらなる発展の期待 - iOSDC 2016Swiftのこれまでの動向のまとめと 今後のさらなる発展の期待 - iOSDC 2016
Swiftのこれまでの動向のまとめと 今後のさらなる発展の期待 - iOSDC 2016
 
Fearless From Monolith to Serverless with Dynatrace
Fearless From Monolith to Serverless with DynatraceFearless From Monolith to Serverless with Dynatrace
Fearless From Monolith to Serverless with Dynatrace
 
ITT 2015 - Vincent Garrigues - Continuous Integration at SoundCloud
ITT 2015 - Vincent Garrigues - Continuous Integration at SoundCloudITT 2015 - Vincent Garrigues - Continuous Integration at SoundCloud
ITT 2015 - Vincent Garrigues - Continuous Integration at SoundCloud
 
Make Your Testing Groovy
Make Your Testing GroovyMake Your Testing Groovy
Make Your Testing Groovy
 

More from gerbille

Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todaygerbille
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLgerbille
 
Speed in the Opera mobile browsers
Speed in the Opera mobile browsersSpeed in the Opera mobile browsers
Speed in the Opera mobile browsersgerbille
 
Speed in the Opera mobile browsers
Speed in the Opera mobile browsersSpeed in the Opera mobile browsers
Speed in the Opera mobile browsersgerbille
 
What's new in the Opera mobile browsers
What's new in the Opera mobile browsersWhat's new in the Opera mobile browsers
What's new in the Opera mobile browsersgerbille
 
Developing HTML5 apps for TV
Developing HTML5 apps for TVDeveloping HTML5 apps for TV
Developing HTML5 apps for TVgerbille
 
Webgl para JavaScripters
Webgl para JavaScriptersWebgl para JavaScripters
Webgl para JavaScriptersgerbille
 

More from gerbille (7)

Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of today
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGL
 
Speed in the Opera mobile browsers
Speed in the Opera mobile browsersSpeed in the Opera mobile browsers
Speed in the Opera mobile browsers
 
Speed in the Opera mobile browsers
Speed in the Opera mobile browsersSpeed in the Opera mobile browsers
Speed in the Opera mobile browsers
 
What's new in the Opera mobile browsers
What's new in the Opera mobile browsersWhat's new in the Opera mobile browsers
What's new in the Opera mobile browsers
 
Developing HTML5 apps for TV
Developing HTML5 apps for TVDeveloping HTML5 apps for TV
Developing HTML5 apps for TV
 
Webgl para JavaScripters
Webgl para JavaScriptersWebgl para JavaScripters
Webgl para JavaScripters
 

Recently uploaded

Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Recently uploaded (20)

Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

Device dis(orientation)?

  • 1. Device (dis)Orientation? Luz Caballero @gerbille
  • 2. • What is it? • Some math you need to know • Code • Support and implementations • Tips and tricks
  • 4. static / one off dynamic / interactive * image sources: http://mygadgetnews.com/tech/apple-looking-to-radically-improve-maps-and-location-services-in-ios-5 http://www.sub5zero.com/top-10-racing-games-iphone/
  • 7. QuickTime™ and a decompressor are needed to see this picture. (back up plan!)
  • 9.
  • 11.
  • 12. QuickTime™ and a GIF decompressor are needed to see this picture.
  • 13. If you want to apply a rotation: V = R(gamma, y’’).R(beta, x’).R(alpha, z).Vo V= .Vo 3rd 2nd 1st
  • 17. server.js α, β, ɣ α, β, ɣ remote.js model.js
  • 18. remote.js: var ws = new WebSocket('ws://10.112.0.139:8080/'); //listen to device orientation window.addEventListener('deviceorientation', function(e) { if (ws.opened) { ws.send(JSON.stringify({ alpha: e.alpha, beta: e.beta, gamma: e.gamma })); } });
  • 19. model.js: window.addEventListener('DOMContentLoaded', function init() { //connect to server using websockets var ws = new WebSocket('ws://10.112.0.139:8080/'); ws.onopen = function() { ws.onmessage = function(e) { var data = JSON.parse(e.data), avalue = data.alpha / 180 * Math.PI, bvalue = data.beta / 180 * Math.PI, gvalue = data.gamma / 180 * Math.PI; teapot.rotation.set(gvalue, avalue, -bvalue); }; }; });
  • 21.
  • 22. luzc.github.com/webtests/ • orientation • compass • motion
  • 23. Tested running ↑N ↑up ↑up luzc.github.com/webtests/orientation in a Samsung Galaxy 2 and an iPhone (iOS6), on α β ɣ February 18, 2013 270 0 0 360/0___|___180 -90___|___90 -90/270___|___90 Chrome for Android | | | 90 0 180 360/0 0 0 270___|___90 -90___|___90 -90___|___90 Firefox for Android | | | 180 -180/180 0 0/360 0 0 Opera Mobile for 90___|___270 -90___|___90 -90___|___90 Android | | | 180 -180/180 0 0/360 0 0 90___|___270 -90___|___90 -90___|___90 Safari for iOS6 | | | 180 0 -180/180 0/360 0 0 Specification 90___|___270 -90___|___90 -90___|___90 | | | 180 -180/180 0
  • 25. Holding your device THE RIGTH WAY™ How FF thinks you should hold How Opera (and Chrome) think your landscape device you should hold your landscape device
  • 26.
  • 28. You may want some buffering https://github.com/richtr/Marine-Compass
  • 30. • rotationRate • acceleration • accelerationIncludingGravity • interval
  • 31. run luzc.github.com/webtests/motion in a Samsung Galaxy Tab 2 and iOS6 • acceleration (Safari) • accelerationIncludingGravity (Safari, Opera, FF) • rotationRate (Safari) • interval (Opera, Safari, FF)
  • 32. window.addEventListener('devicemotion', function(e) { if(e.acceleration){ //e.acceleration.x //e.acceleration.y //e.acceleration.z } if(e.accelerationIncludingGravity) {//e.accelerationIncludingGravity.x //e.accelerationIncludingGravity.y //e.accelerationIncludingGravity.z } if(e.rotationRate){ //e.rotationRate.alpha //e.rotationRate.beta //e.rotationRate.gamma } if(e.interval){ //e.interval } }); } }); } }); } }); } });
  • 33. Things to remember: • Angular position, angular speed and acceleration • Intrinsic axes of rotation • Rotations have to be applied *in order* • Singularity in alpha/gamma • 3D libraries / languages can make your life easier • Browser support but different implementations • BYO calibration • Portrait/landscape matters • You may want some buffering • Device motion has only partial support
  • 34. That’s all :) Thanks!! Luz Caballero @gerbille github.com/luzc