Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8703759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:56:20+00:00 2026-06-13T02:56:20+00:00

I’m trying to draw a 2D image on the screen that is always facing

  • 0

I’m trying to draw a 2D image on the screen that is always facing “up”. If the user is rotating their phone, I want to ensure my 2D object does not rotate with the device; it should always “stand vertical”. I want to compensate for the user tilting left or right, but not tilting away or towards themselves.

I’m using CoreMotion to get Pitch, Roll and Yaw from the device, but I don’t understand how to translate the points into the direction up, especially as the user rotates the device. Ideally, I can translate these 3 numbers into a a single value that will always tell me which way is up, without having to relearn all of Trigonometry.

I’ve looked at the 3D teapot example but it doesn’t help because this example is 2D and I don’t need tilt away/tilt towards. Also, I don’t want to use the compass/magnetometer because this needs to run on the iPod Touch.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:56:20+00:00Added an answer on June 13, 2026 at 2:56 am

    Look at image to better understand what I’m saying:

    enter image description here

    So you are only interested in XY plane. Accelerometer always measures the acceleration of the device relative to freefall. So when you’re holding device as it is on image the acceleration value is (0, -1, 0). When you tilt device 45 degrees clockwise the value is (0.707, -0.707, 0). You can get the angle by calculating the dot product of current acceleration value and some reference axis. If we are using an up vector the axis is (0,1,0). So the dot product is

    0*0.707 - 1*0.707 + 0*0 = -0.707
    

    Which is exactly acos(-0.707) = 45 degrees. So if you want your image to stay still you need to rotate it in reverse side, i.e. -45 degrees in XY plane. If you want to ignore the Z value then you take only X and Y axes: (X_ACCEL, Y_ACCEL, 0). You need to renormalize that vector (it must gave magnitude of 1). Then calculate an angle as I explained.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.