Jump to content
  • Advertisement
Sign in to follow this  
jm_hewitt

Lin Al question: finding a matrix/quat

This topic is 5058 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

First time poster in this area. I'd ask a math professor if I knew one.... Given 3 axes i, j, k and new axes i',j', k' can you find a matrix/quaternoion/something that rotates all directoinal vectors in i, j, k to be defined in i', j' k'? Right now a guy at work is asking for all this information from me which I htink is unnecessary, but I am an undergrad questioning the authority of someone with a PhD......

Share this post


Link to post
Share on other sites
Advertisement
In this forum I see you get hw problems....

If you fear this is a math/hw problem (which it isnt, its a plane flying around the globe doing barrel roles problem), can you tell me yes it can be done and send me in a general direction of where to look?

Share this post


Link to post
Share on other sites
Read the other threads about rotations here.

You have to understand that a triplet i,j,k is equivalent to :

- a frame
- a linear transformation from the canonical frame to i,j,k (*)
- a matrix with columns i,j,k (Say M)

(*) If i,j,k form an (edit cf Paradigm Shifter, thx) : - right handed - orthonormal base, then the transfo is a rotation, and M a rotation matrix which can be transformed into a normalized quaterinon.

Thus what you want is obvious :
(EDIT : wrote too quickly earlier)
R = inverse(M') * M

Well you just have to learn the basics of linear algebra. there is enough on the www. ANY 3D coder knows all this stuff by heart, making it as obvious as adding integers. That's ultimately necessary to be totally fluent with such concepts. Writing 3D video games needs a hell more than what you probably think.

EDIT :

OK I'll be more kind, to show you how it works. If the said vector has local (IJK) coords Vi, Vj, Vk, then :

(Vi',Vj',Vk') = R*(Vi,Vj,Vk)

Raplece R and read left to right :

The first step is from local coords (i,j,k) to world (x,y,z)

(Vx,Vy,Vy) = M*(Vi,Vj,Vk)

Then from world to local (i',j',k') coords.

(Vi',Vj',Vk') = inverse(M') * (Vx,Vy,Vy)

[Edited by - Charles B on September 13, 2004 1:44:15 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Charles B
Read the other threads about rotations here.

You have to understand that a triplet i,j,k is equivalent to :

- a frame
- a linear transformation from the canonical frame to i,j,k (*)
- a matrix with columns i,j,k (Say M)

(*) If i,j,k form an orthonormal base, then the transfo is a rotation, and M a rotation matrix which can be transformed into a normalized quaterinon.



If and only if det(M) == +1. If it's -1 then it will have a reflection component also (cf change from right handed to left handed system).

Share this post


Link to post
Share on other sites
Haha, I am a 3d coder (THE 3d coder at my company, go figure) and I dont know this by heart. I took Lin Al before realizing it'd be one of the most important classes and now regret skipping half of it. I was pretty sure that it was possible, I usually remember what can be done but forget how its done.

I am going off of htis paper:
http://www.math.hmc.edu/calculus/tutorials/changebasis/changebasis.pdf

and cant beleive how simple this is. I probably should take a refresher on Lin Al....

What reference books do you recommend? I don't like my college textbook.

Share this post


Link to post
Share on other sites
You basically have to construct a rotation matrix to do this. Its a lot of work, and you make a lot of assumptions becuase there are an infinite amount of was to rotate one vector into another, which is all you're doing.
Solve the equation :

Rx=x'

You'll have 3 equations, and if you use Euler angles you'll have 3 unknowns.

Also, what do you mean given axis i,j,k and i' j' k', are those all vectors? Like is i=<1,0,0> j = <0,1,0> k = <0,0,1> and you need to go to i' = <i_x,i_y,i_z> ....

Assuming this is what you mean, I just realized its easy.
Your rotation matrix, since how you apply it is a matrix multiplication, is going to just be your axis in row form, so:

assuming the new 3 axis vectors are
i' = <i_x,i_y,i_z>
j' = <j_x,j_y,j_z>
k' = <k_x,k_y,k_z>

your Rotation Matrix would be :

|i_x i_y i_z |
|j_x j_y j_z |
|k_x k_y k_z |

so long as i', j', k' are all normalized.

Share this post


Link to post
Share on other sites
Okay, to fully show my ignorance here is the context of the problem:

You have a camera flying around the earth, like a plane. It needs to move 50 meters forward (forget if its straight 50 meters or around the greater circle 50) and you need to update the camera preserving altitude and what the camera is looking at.

I, rushing to code texture look ups and bad LOD functions, asked our algorithms person (who developed our representation of the earth), given the up vector, camera direction and view position and that distance moved, could he give me the updated info. And it kind of spiraled down from there....


Share this post


Link to post
Share on other sites
Quote:

Haha, I am a 3d coder (THE 3d coder at my company, go figure)


;p I know. I have met many people like you in my earlier game prog jobs. Some were rather worried when I left, I used to be the mecano of math bugs. I don't intend to bash but I just can't understand why people can't get it or remeber it. Well in fact I admit it was hard to see the equivalences I mentionned, and to interpret the formulas the first two weeks I had to learn all this stuff at school.

Quote:

What reference books do you recommend? I don't like my college textbook.


Frankly no idea. I've learned such stuff decades ago. ;) Sometimes with memory leaks, I try to figure out math stuff on paper. Sometimes with 2D/3D schemes, and I try to visualize things in my head spatially. I think it's always better to learn this way. Once you get it with mental pictures, it's forever printed. Text demonstrations do not last so long.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!