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.

Geek Culture / need help with angles (maths question)

Author
Message
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 17th Oct 2008 14:55 Edited at: 17th Oct 2008 14:56
hey guys...

this is probably really easy but i'm no good at all this maths.
well say i have an angle(0-360) and what i'm trying to do is get the X & Y increments. sorry if you don't understand, i cant explain stuff properly so heres picture that may help explain things.



umm... i think it could be explained as:
getting the new x/y (increments or position) according to the angle

so yeah i'm just wondering if i could get any help how to work that out?

i hope you guys know what i'm on about because i dont :p

shaunrw...

WWW.SHAUNRW.WEBS.COM

Attachments

Login to view attachments
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 17th Oct 2008 16:28
Does it give you the length of the hypotenuse?

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Oct 2008 16:51
In your diagram Y = X * tan(40) (where "tan" is the trig tangent function and * is multiplication). So, if X = 50 then Y = 50 * tan(40) = 50 * 0.8391 = 41.95 (approx).

Your X and Y values correspond to an angle of about 21.8 degrees.
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 17th Oct 2008 16:59 Edited at: 17th Oct 2008 17:03
Quote: "Does it give you the length of the hypotenuse?"

no it doesn't

ok i will try explain more of it.

in my game i have the 2d character, and i have him rotate so the player can turn corners and what not. and i have a variable for the angle(angle#) of the character. so i need the x/y increments to move the player in the direction he's facing. i would use the move sprite command in dbp, but i find that it would seem to be easier to just move the player with the x / y co-ords for when i insert my collisions.

hope you understand me.

[edit]
Green Gandalf posted while i was writing my post. lol
thank you green i will see how that works for me
[/edit]

shaunrw...

WWW.SHAUNRW.WEBS.COM
Ravey
Retired TGC Developer
22
Years of Service
User Offline
Joined: 2nd Nov 2002
Location: Southern TGC Nerve Centre
Posted: 17th Oct 2008 19:31
Shaunrw - if you know the angle then you can do this to move your character in that direction:

inc playerX# , sin( playerAngle# ) * playerMoveSpeed#
inc playerY# , cos( playerAngle# ) * playerMoveSpeed#

..if that's what you were after

Dave Milton
TGC Team
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 17th Oct 2008 20:26
thank you Ravey exactly what i'm after

when i think about it, i really should of posted this in the dbpro board. i think

well thanx for helping me


shaunrw

WWW.SHAUNRW.WEBS.COM

Login to post a reply

Server time is: 2024-11-20 18:24:22
Your offset time is: 2024-11-20 18:24:22