Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quaternion Cameras and projectile vectors

In our software we have a camera based on mouse movement, and a quarternion at its heart.

We want to fire projectiles from this position, which we can do, however we want to use the camera to aim. The projectile takes a vector which it will add to its position each game frame.

How do we acquire such a vector from a given camera/quaternion?

like image 976
Tom J Nowell Avatar asked Feb 03 '26 18:02

Tom J Nowell


1 Answers

The quaternion doesn't represent a direction, it represents a rotation. You can define a vector that points in the direction that your camera is pointing initially (e.g. (0,0,1)) and transform it using the rotation represented by the quaternion.

like image 176
kloffy Avatar answered Feb 06 '26 06:02

kloffy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!