Tuesday, December 17, 2019

mathematics - Is there a better way of determining direction to turn?


You have an entity A that you want to turn towards another entity B. One way to determine the direction to turn is to compute the cross-product of the direction vector of A with the vector from AB. If the value of z is positive, then you turn right. If the value of z is negative, you turn left. Is this the only way of determining which way to turn?




Answer



If you're storing your rotations as quaternions (which you probably should), you could use a quaternion lerp function to lerp from your initial rotation to the rotation you want to be at (i.e the rotation given by the vector AB with whatever your up vector is).


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...