Archived

This topic is now archived and is closed to further replies.

radar for spaceshooter

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi anyone knows the radar displays from privateer or wing commander? the middle of the radar screen is in front of you, the farer its away from the center the farer you must rotate to face it. a point in the most outer region is behind you. (dont know if anybody understands this...) i know the position of my spaceship, the rotation(quaternion) and the same of the spaceship to display on the radar. i can calculate the distance from the radar center to the displayed point by the dot product of the direction-vector of my spaceship and the vector from my spaceships position to the position of the other spaceship. but i dont know how to calculate the angle to rotate the point around the center.(if the other spaceship is left/right/up/down) hope somebody can help.

Share this post


Link to post
Share on other sites
You´ll have to get the angle between the heading of the radar and that of the other ship:

  
//It we say that the origin of our ship is (0,0,0), we do this:

//Note: To move the ship and other thing, substract the ship´s

// origin from all ships´ origins


float r = acosf( DotProduct( heading, ship.origin ) / (heading.Magnitude() * ship.origin.Magnitude() ) );

It you should be in 2d, it´s just the same....We just remove z from all calcs....

Share this post


Link to post
Share on other sites
hmm... this formula doesnt look richt, perhaps my explanation wasnt so good.

i know the angle how far the other spaceship is away from center( dot(heading,vector_to_other_spaceship)), but i dont know the direction:-(

Share this post


Link to post
Share on other sites