SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

Similar a 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 a 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
 

Más de 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
 

Más de 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
 

Último

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 

Último (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

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