Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Angle between two object  (Read 5967 times)

0 Members and 1 Guest are viewing this topic.

floppa_dev

  • Newbie
  • *
  • Posts: 11
    • View Profile
Angle between two object
« 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Angle between two object
« Reply #1 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> 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. :)
« Last Edit: November 22, 2022, 03:56:10 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

floppa_dev

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Angle between two object
« Reply #2 on: November 23, 2022, 02:30:11 pm »
ok thx

GlendaRagin

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Angle between two object
« Reply #3 on: September 25, 2023, 07:02:53 am »
Thanks alot.

 

anything