c# - 3D rotation, given two specified directions -
i have 2 perpendicular unit vectors, p , q; think of being embedded in rigid object in 3d space. wish rotate object p points along positive x-axis , q points along positive y-axis.
i programming in c# , using quaternions compute rotations. how create quaternion perform desired rotation?
if imagine inverse operation of quaternion, know point (1,0,0) goes p, , (0,1,0) goes q. similarly, point (0,0,1) go point z equal cross product of p , q.
therefore have matrix representation of inverse rotation. first column p, second q, third p cross q.
so matrix rotation want given transpose of matrix, i.e. first row p, second row q, third row p cross q.
so recommend call library routine convert matrix quaternion form.
you may interested in document doom3 explaining algorithm id software used converting matrix quaternion - including optimised x86 assembler code.
orthogonal matrices
if have matrix m columns (a,b,c) forming orthonormal set, know a'a = b'b = c'c = 1, a'b = ... = c'a = 0.
therefore m'm = i.
if multiply on left m, , on right inv(m) find:
m.m'.m.inv(m) = m.inv(m) => m.m'.(m.inv(m)) = m.inv(m) = => m.m' =
and so, if have orthonormal columns, must have orthonormal rows, , matrix m called orthogonal matrix.
Comments
Post a Comment