![]() |
| | #1 |
| & the hat of GPL slaying Join Date: Sep 2001
Posts: 5,732
| 3 axis accelerometer calculations For the angles I'll be using a 3 axis accelerometer that is setup so that when it is flat the Y axis value is equal to the force of gravity, X would be along the front of it, and Z would be along the length of it. The arrows in the attached picture indicate the direction of positive values for the force. There are only two useful rotations to consider: Rotation in the XY plane and YZ plane. I have labeled this as Θr and Θp (roll and pitch). Rotation in the XZ plane is meaningless in terms of the application and would not be measurable by the device. First considering counter-clockwise rotation in the XY plane. I came up with: x = sin Θr y = cos Θr which makes sense as the value of Θr approaches pi/2 sin increases and cos decreases. Considering rotation in the YZ plane such that the the positive Z "drops down". I came up with z = sin Θp y = cos Θp Now through the use of just looking at a model (made of knitting needles ) I looked at the case were there is rotation in both the XY and YZ planes. It seems in that all three will get smaller as the oppose angle increases. So I got:x = sin(Θr)*cos(Θp) y = cos(Θr)*cos(Θp) z = cos(Θr)*sin(Θp) Now in reality I'll have x,y,z and need to get Θr and Θp. So by doing a bit of elimination and setting equations equal I get: Θr = arctan(x/y) Θp = arctan(z/y) Does this seem right or did I make a mistake somewhere? |
| Thantos is offline | |
| | #2 |
| .com Join Date: Jan 2008 Location: Kent, UK
Posts: 116
| What have you defined lowercase x,y and z to be? I couldn't see it in your post |
| Stonehambey is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| need help making a dot bounce up and down y axis in this prog | redwing26 | Game Programming | 10 | 08-05-2006 12:48 PM |
| AXIS and C++ | bman1176 | C++ Programming | 0 | 03-29-2006 11:00 AM |
| Axis based on 2 Vectors | durban | Game Programming | 1 | 11-10-2005 04:38 PM |
| Graph axis | fkheng | C Programming | 2 | 07-25-2003 07:03 AM |
| How do I get these calculations correct? | nadeni0119 | C++ Programming | 10 | 04-07-2003 11:09 AM |