Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [SOLVED] I have two XY positions. How do I find the angle?

Author
Message
basicFanatic
2
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 25th Sep 2018 15:30

Sin and Cos always messes me up! I tried following the tutorial guide, but didn't quite get it. Need to print it out and try again.

In the meantime, can someone tell me how to magically transform those four values into an angle?

meX = 125
meY = 17
targetX = 60
targetY = 89

The author of this post has marked a post as an answer.

Go to answer

Bengismo
1
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 25th Sep 2018 15:35 Edited at: 25th Sep 2018 15:43
This post has been marked by the post author as the answer.
Angle# = ATan2(TargetY-meY,TargetX-MeX)

EDIT:

Alos....ATanFull can be used but it depends on if you want 0 degrees to be straight upwards on the screen or to the right as per AGK's and general maths.
basicFanatic
2
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 25th Sep 2018 17:18 Edited at: 25th Sep 2018 17:19
Thanks! ATanFull worked beautifully. I didn't have to think at all
Phaelax
DBPro Master
16
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Sep 2018 16:02
In case you ever wanted to write your own atanfull function

Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Login to post a reply

Server time is: 2019-09-19 20:14:20
Your offset time is: 2019-09-19 20:14:20