Hi guys, can someone help me out with this 3d math problem?
As shown in the picture, I’d like to rotate my camera so that the crosshair will point to the center of the yellow ball. But I must do it smoothly.
Now, I got a customized angular velocity according to my formula. And I need to produce a DeltaRotator so that I can apply it to my CameraManager.
- Get the
ForwardVectorof the camera, as well as the vector from
CrossProductof these 2 vectors gives me an
AxisVectorperpendicular to them.
- Construct a quaternion with this
AxisVectorand my angular velocity(namely, the angle to rotate in the current frame).
- Convert quaternion to rotator as
DeltaRotator, and use it to rotate my camera.
When the camera is facing +X axis(namely, ForwardVector.X > 0), everything works perfectly. But when the camera is facing -X axis, the Pitch of DeltaRotator is always reversed.
Why is this? Can anyone point out the mistake here? I really want to figure it out!
Thank you! Happy 2021!
As @CyberSquirrel_ said, I can solve this problem by interpolating from the original rotation to the final rotation. I’m just really curious about the mistake I made in the approach I posted here, cause I still feel that it seems to be correct…