Finding a point from given angle and radius
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.
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.
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.
February 18, 2003 06:21 AM
So what is "Player->direction", and why do you multiply it by 10?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement