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.

Dark GDK / Angle between two points in 2D...

Author
Message
Ludo
16
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: UK, Oxfordshire
Posted: 24th Jun 2008 23:24 Edited at: 24th Jun 2008 23:47
Greetings, I am trying to work out how the angle between two points in 2D space (i.e. the width and height of my screen).

I have heard about Atan() but I am not sure how to use it.

Could someone explain it to me and how I access it?

Cheers.

/Ludo

EDIT: Na, Atan doesn’t work like I want, I need the angle from a point to another point so if I place a sprite1 and sprite2 you can get to sprite2 from sprite1 by going forward if you facing 180 degrees at sprite1.
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 25th Jun 2008 05:54
From the Master



This was published in the 7th magazine its in DBPro but the translation should be easy

Codger

System
MacBook Pro
Windows XP Home on Boot Camp
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Jun 2008 06:24 Edited at: 25th Jun 2008 06:25
I started translating it. I'm stuck with how to concatenate the strings. Other than that, here's the code:

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Jun 2008 06:34 Edited at: 25th Jun 2008 06:36
Well, here it is without the angle printed. I also added an easy way to edit the line size:



You just will have to make a way to print the angle with something like this:



But, C++ isn't so simple. Try using strcat, but better than I did.
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 25th Jun 2008 07:21
Or just use atan2() as defined in math.h.

Login to post a reply

Server time is: 2024-11-20 15:30:22
Your offset time is: 2024-11-20 15:30:22