Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Rotate a 3D vector

by Anonymous Monk
on Oct 18, 2004 at 08:55 UTC ( #400097=note: print w/replies, xml ) Need Help??

in reply to Rotate a 3D vector

RX= 1 0 0
0 cos φ - sin φ
0 sin φ cos φ

RY= cos θ 0 sin θ
0 1 0
0 -sin θ cos θ

RZ= cos ψ -sin ψ 0
sin ψ cos ψ 0
0 0 1
Then your rotation matrix is RX * RY * RZ, with θ the amount of rotation around the X axis, φ the amount of rotation around the Y axis, and ψ the amount of rotation around the Z axis.

Replies are listed 'Best First'.
Re^2: Rotate a 3D vector
by Anonymous Monk on Apr 18, 2010 at 10:29 UTC
    Sorry for bumping an old thread.. i hope this saves a bit of someones time: Ry is wrong, it should be:
    cos(th) 0 sin(th) 0 1 0 -sin(th) 0 cos(th)
    rgds, Mitja
Re^2: Rotate a 3D vector
by Anonymous Monk on Jan 26, 2010 at 19:47 UTC
    how do you find the angles , , and between two vectors?
      To find the angle between the two vectors, you need to normalize them (so they have length of 1 unit) by doing this (v is the vector you want to normalize):
      float distance = sqrt(v.x*v.x + v.y*v.y + v.z*v.z); v.x = v.x/distance; v.y = v.y/distance; v.z = v.z/distance;
      Then find the dot product of the two normalized vectors (Va and Vb):
      float dotProduct = Va.x*Vb.x + Va.y*Vb.y + Va.z*Vb.z;
      This gives you the cosine of the angle, so simple do:
      This will give you the angle. I think this post was a bit late :S

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://400097]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2023-01-31 04:42 GMT
Find Nodes?
    Voting Booth?

    No recent polls found