SFML community forums

General => Feature requests => Topic started by: floppa_dev on November 22, 2022, 03:27:24 pm

Title: Angle between two object
Post by: floppa_dev on November 22, 2022, 03:27:24 pm
how to calculate angle between two sprites/objects? :) ik this was asked before but i am a noob so i didnt understand
Title: Re: Angle between two object
Post by: eXpl0it3r on November 22, 2022, 03:54:27 pm
I order to calculate an angle you'll need at least three points or a reference system (e.g. relative to sprite x on an unit circle).

Either way it's a mix of vector math and trigonometry and that's as basic as it gets.
For SFML 3, we've actually added one option to the sf::Vector2<T> (https://github.com/SFML/SFML/blob/master/include/SFML/System/Vector2.hpp#L126) class, so this then might already make things slightly easier.

You can't really avoid learning some of vector math and trig and learn how to apply it.

If you enter for example "angle between two vectors" into a web search engine, you'll find some good explanations. :)
Title: Re: Angle between two object
Post by: floppa_dev on November 23, 2022, 02:30:11 pm
ok thx
Title: Re: Angle between two object
Post by: GlendaRagin on September 25, 2023, 07:02:53 am
Thanks alot.