vb.net - Orientate a rotation Vector in 3D space to face a destination -


i got 2 position vectors in 3 dimensional space:

dim position vector3 dim destination vector3 

i got rotation vector, used rotate object. contains yaw, pitch , roll values (=> ranges 0 pi * 2)

i want rotation vector point correct orientation, object in end points @ destination vector, being @ position vector.

i have no idea how accomplish though.

it's been while since did 3d stuff, hence going conceptual-only answer.

you can construct 3 orthogonal unit vectors , combine rows in matrix. matrix transformation. know 1 vector already...

forward = to_point - from_point 

now need "up" , "right" vector, can calculated using cross-product, provided have sort of world reference vector (otherwise solution space infinite). example, "up" vector should defined.

this mean solution may suffer gimbal lock if "forward" vector becomes parallel "up" vector. in case, cross product come out small (or zero) , break. that's because you're trying solve system 2 degrees of freedom , using assumption fill 1 of those.

anyway...

right = forward cross 

then can fix up-vector:

up = right cross forward 

the ordering of cross-product operations above assume right-handed system. if world left-handed, reverse ordering of 2 vectors being crossed.

so, have 3 orthogonal vectors represent object's transform. slap these matrix. rows (or columns, depending on side of equation matrix applied) depend on how define co-ordinate system. used have x being right, y being forward, , z being up.

now have object's 'neutral' rotation matrix, can apply ordinary pitch, roll , yaw rotations using standard matrix transformations. indeed can construct "local" rotation matrix applying pitch, roll , yaw identity matrix, , multiply matrix constructed earlier.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -