# Problem With Angles

This topic is 4889 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey guys, I've got a rather easy question for all of you veterans out there. I finally got all of my classes set up for my pong game but I am having a tough time working out the equations to effectively pass an angle to a function and have it generate the change in x and y (slope I presume) for my vertices. I bought a book on game physics, but it starts out a little further than this basic concept. Couldnt find anything on google either about converting angles to slope. Any help I can get would be greatly appreciated. Thanks everyone.

##### Share on other sites
where Ø is the angle
∆X=cos(Ø)∆Y=sin(Ø)

##### Share on other sites
Hmm, ive tried that and I must be doing something wrong. Here's the line of code I am using:

Rect->Set_Position(Rect->myX plus (float) cos(90), Rect->myY plus (float) sin(90));

Change the word plus to a plus sign, for some reason it filtered that character. If I understand this correctly, depending on which way the coordinates of the screen are oriented with angles, it should go either straight up, down, left or right. It actually did none of those, it went in sort of a south south west angle. I could be doing something completely wrong. Oh BTW, the Set_Position function takes two arguements, x and y and in that order. This just sets the position of the object. Thanks guys.

##### Share on other sites
c++ math functions work with radians, not degrees. (I assume this is c++.)

Also, although +'s are for some reason filtered in the preview, they actually show up in the post :-)

##### Share on other sites
Ahhh, I bet that's what I'm doing wrong. Let me try that out and I'll let you know what happens. Thanks!

##### Share on other sites
That works, awesome! I tried finding some documentation on the cos and sin methods but was short on information. I was about to pull my hair out. Thanks a million.

Just as reference for others in the future:

1 degree = 0.0174532925 Radians

macros suck

##### Share on other sites
Although I don't see any way that specific macro could be bad (I'm sure the gurus will find some) I prefer to multiply by:
const float DegToRadf = whatever

##### Share on other sites
Quote:

If you used 180, it would cast the answer to an integer.
Does this mean I'm a finally a guru? =)

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634059
• Total Posts
3015291
×