Advertisement

Finding a point from given angle and radius

Started by February 17, 2003 11:45 AM
4 comments, last by Bluefox 22 years ago
Hi, I am trying to find a point from given angle a radius values. So far I have come up with the below code, but it doesnt quite work. Please can you help? float ang = (3.14159265/180)*(Player->direction*10); //convert degrees to radians ang += Player->gunport1ang; //already converted to radians xpos = 400 + (sin(ang)*Player->gunport1rad); ypos = 300 + (-cos(ang)*Player->gunport1rad);
What angle are you actually trying to fugure out. Some explanation of what the variables are for is usually helpful.
Advertisement
Of course, silly me.

Player->gunport1ang - the angle to which the new point will be
Player->gunport1rad - the radius of how far from given x and y
ang - the players current angle + the gunport angle

Basically I am making a ship, which has guns attached to each side. So when the ship turns round the gunports will also move round. If you still not sure what im ramballing on about then i can post a demo of the explanation, done in a another program.
So what is "Player->direction", and why do you multiply it by 10?
Player->direction - is the players angle. its currently 0 to 35, so its multiplied to give the correct angle 0 to 350 degrees.
So what result do you expect, and what do you get?

This topic is closed to new replies.

Advertisement