My Math Forum From relative rotation to absolute rotation in 3D space

 Algebra Pre-Algebra and Basic Algebra Math Forum

 August 27th, 2010, 12:49 AM #1 Newbie   Joined: Aug 2010 Posts: 1 Thanks: 0 From relative rotation to absolute rotation in 3D space First of all, I only had very basic education in maths in high school. I have been trying to solve this problem for two days now, but can't figure it out. Maybe a kind soul can help me. All of this is in Euler notation. In truth, I only heard about Quaternions yesterday and still don't understand them fully, and I never worked with rotation matrices before. Imagine two objects in a 3D space. Let's call the first object the independent object, and the second the dependent object. The independent object is at a set point in space, but it can rotate horizontally (Euler z-rotation). The dependent object should 'follow' the the independent object when it rotates, so that the relative position and rotation of the dependent object always stays the same. I have the relative position and rotation numbers available (in Euler notation), and I need to convert those to the absolute position and rotation values for any given Z (horizontal) rotation of the independent object. For the position it was easy, it was a matter of measuring the distance between the two objects, and then use sine and cosine with the z-rotation of the independent object to calculate the new x-y-z coordinates. I am stuck with the rotations however. Because, for example, x-rot=30, y-rot=50, z-rot=0 does not have the same relative rotation as x-rot=30, y-rot=50, z-rot=45. Changing the z-rotation requires the x-rotation and y-rotation to change as well, if you want to keep the same relative rotation. This is just how the Euler notation system works right? So like the title says, I need to convert the relative rotation of the dependent object to absolute rotation, where the z-rotation of the independent object is variable. I think it's similar to a satellite situation? I DO have the relative rotation values available in Quaternion as well, but like I said, I don't understand them. Telling me to multiply two Quaternions with different rotation values (or something like that) doesn't really help, because I have no idea how to do that, unless the steps are explained in detail. So if possible, can you tell me how to do it all in Euler notation? Thank you very much in advance!
 August 27th, 2010, 09:01 PM #2 Member   Joined: Aug 2009 Posts: 69 Thanks: 0 Re: From relative rotation to absolute rotation in 3D space Normally, (and by "normally" I mean the method that DirectX uses) where V is a column vector, and X, Y, and Z are left-handed rotation matrices that rotate around the corresponding axis by their corresponding angle (IE matrix x rotates V around the x axis by x degrees): Z*Y*X*V=V' Therefore, where the parent object is at the origin, the child object's *position* will be at Z*Y*X*Position. Finding out the rotation of the child object is a bit harder. Lets say the child object's rotation matrices are X1, Y1, and Z1. Where the child object is at the origin, every vertex of it will be rotated by Z1*Y1*X1*point. To figure out the new rotation of this object, we need to multiply the parent's rotation matrices by the child's rotation matrices. That means (where matrices Z,Y,X are the parent's rotation matrices and Z1,X1,Y1 are the child's rotation matrices) Z*Y*X*Z1*Y1*X1*Vector + Z*Y*X*OffsetVector = final position of any of the child object's vertexes (where Vector is the vertex's position, and OffsetVector is the offset of the whole object). I'm guessing you're using this with a 3d graphics library, and with higher level stuff, you usually give three angles and a position for each object. Like I've said, Z*Y*X*OffsetVector gives the object's final position, but how do we find the euler angles to rotate the object? Basically what we are saying is, for some three rotation matrices X2,Y2,Z2 (obeying the same conventions as above), Z2*Y2*X2*Vector=Z*Y*X*Z1*Y1*X1*Vector therefore Z2*Y2*X2=Z*Y*X*Z1*Y1*X1 What Z*Y*X condenses to is this matrix: So, where A=Z2*Y2*X2, B=Z*Y*X, and C=Z1*Y1*X1 (you should be able to grab matrices B and C through whatever graphics library you're using) A=B*C then lets say D=B*C so A=D according to the matrix above, -sin(x)=D31 x=-asin(D31) or 360-x. You can do a similar thing for angles y and z also. You can solve for one of the solutions like so: Code: if abs(D31)<>1 y=-asin(D31) x=atanfull(D32/cos(y),D33/cos(y)) z=atanfull(D21/cos(y),D11/cos(y)) else r1.z=0 r1.y=posneg(D31,90) r1.x=atanfull(posneg(D31,D13),posneg(D31,D13)) endif ... function posneg(a as float, b as float) if a>0 then exitfunction b else exitfunction -b endfunction So, in pseudocode: Code: C=grab_object_rotmatrix(child) B=grab_object_rotmatrix(parent) matrix D=B*C if(abs(D31)<>1) y=-asin(D31); x=atanfull(D32/cos(y),D33/cos(y)) z=atanfull(D21/cos(y),D11/cos(y)) else r1.z=0 r1.y=posneg(D31,90) r1.x=atanfull(posneg(D31,D13),posneg(D31,D13)) endif function posneg(a as float, b as float) if a>0 then exitfunction b else exitfunction -b endfunction

 Tags absolute, relative, rotation, space

,

,

,

,

### mmmmXXXy

Click on a term to search for related topics.
 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post Jhenrique Linear Algebra 0 January 21st, 2014 03:23 PM mmmmxxx Calculus 3 November 5th, 2012 11:45 AM nappz Algebra 0 January 23rd, 2011 01:07 AM Ryan Computer Science 0 December 27th, 2007 03:04 PM mmmmxxx Algebra 2 December 31st, 1969 04:00 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}