Announcement

Collapse
No announcement yet.

Get new vector based on angle of two vectors

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Whenever you find yourself using arccos, arcsin, or arctangent, 99 times out of 100, you're doing it wrong.
    The only reasonably time to use it is when interpreting 2D user input. And, then, you always want arctan2 (with both dx and dy inputs) rather than asin or acos.

    To find a rotation from vector A to align with vector B, you can find the axis of rotation R as normalize(cross(A, B)). If A is parallel with B, just pick any axis that's normal to the vectors.
    Then construct the third vector for the basis A by crossing A and R. Call this basis matrix Ba. Now, construct the same kind of basis for vector B, call it Bb. The matrix that rotates from A to B is transpose(Ba)*Bb.

    Comment

    Working...
    X