0

I have a problem. I have created an object that will move in X, Y, Z axes in changing directions. I want to use the Quaternionf class as my tool. Knowing the X, Y, Z coordinates of the object and the coordinates of the target point, I want to set Quaternionf towards this point (from the position of the object, of course). The direction from the object point should always be towards the target point. I am attaching pictures showing what I mean.

enter image description here

enter image description here

As you can see, the direction of the object is always facing the target. I will be grateful for your help!

Rubydesic
  • 3,386
  • 12
  • 27
Adixe
  • 119
  • 7

1 Answers1

0

There's no one unique rotation that faces the target, but you can use Quaternionf#lookAlong(Vector3fc, Vector3fc), and for the dir parameter use targetPos.sub(initialPos).

Rubydesic
  • 3,386
  • 12
  • 27
  • Thank you for your answer! I don't quite understand how to use this method correctly and where and what arguments to give. Could I ask for more details? – Adixe Feb 20 '23 at 17:19