0
\$\begingroup\$

So i want to rotate particles towards a point and i've already figured out how to calculate the angle and the rotation axis.

Currently what i do is simply use a 3 dimensional matrix, apply the rotation and then extract the euleric angles from the matrix using joml.

Now using the result i have the problem that the particle is also using the z rotation, messing up the orientation of the particles texture. The easiest way to fix this would be to only use yaw and pitch, but how do i convert the roation to just a rotation around the x and y axis?

\$\endgroup\$
  • \$\begingroup\$ Sounds like all you need to do is convert your facing direction vector into spherical coordinates. You can think of the theta and phi angles you get that way as yaw and pitch. We have lots of existing Q&A about that kind of conversion, or the Wikipedia article would have everything you need too (though they seem to use a form with phi = 0 at the pole. I'd exchange cosine for sine to place phi = 0 at the equator instead, but you can always just subtract π/2 instead) \$\endgroup\$ – DMGregory Feb 22 at 14:16
  • \$\begingroup\$ What programming language are you using? And are you using Unity? \$\endgroup\$ – user124517 Feb 22 at 14:55
  • \$\begingroup\$ I will take a look into spherical coordinate systems, thanks. And i'm using java and the math library joml \$\endgroup\$ – Masy Feb 22 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.