开发者

How to use gyro z axis on the iPhone?

开发者 https://www.devze.com 2023-04-01 03:30 出处:网络
I\'m using the gyro (does accelerometer and gyro the same on iPhone?) and the X axis and Y axis are working great.

I'm using the gyro (does accelerometer and gyro the same on iPhone?) and the X axis and Y axis are working great.

The Z axis is called YAW, but I just can't understand it. It should change its value to 0 when iPhone on its sides and -1 to 1 when face up and down.

  1. In reality , ever开发者_开发百科y move on the X/Y axis , change also the Z ...
  2. The definition of Z is answer also on the definition of X axis anyway (same?) because Z is not discrete .

I just can't understand the Z axis thing and if there is another way of getting data of current position from iPhone except from this.


The iPhone has an accelerometer and a gyroscope. Here is a very good video explaining both:

http://www.gametrailers.com/user-movie/wiimotion-plus-explained/244882

I may be wrong, but I believe you are using the accelerometer not the gyro. There are going to be 2 values that are always going to be changing if you rotate the iPhone. Imagine or draw your iPhone vertically as a rectangle. Now draw a horizontal line and a vertical line across it. Those are your X and y axis. If you rotate your iPhone with the screen facing you 90 degrees (from portrait to landscape) you are going to see that your x and y values changed from 1 to 0 and from 0 to 1. The values change when the lines you drew before change from horizontal to vertical and from vertical to horizontal.

Imagine The iPhone facing you again. The z-axis is going to be a line going though the iPhone. So if you put your iPhone on a table you are going to see on the app that the x and y-axis are going to be the same (I believe 0) because both lines are flat, and the z-axis is going to be I believe 1 because the line going though the iPhone is vertical. Here is an image showing the lines:

How to use gyro z axis on the iPhone?


(source: garagegames.com)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号