Sign in to follow this  
fightingfalcon

target line

Recommended Posts

I am trying to simulate a target locator line to show which way my aircraft needs to fly in order to find the ground target. Right now, I have no problems if the target is straight ahead and I am not banking right nor left. The problem arises when my target is aft of my aircraft and I am banking right or left. Instead of directing me to fly to the right (I am banking right), it directs me to dive down (I will crash to the ground if I follow the line). Hope that the illustration below helps to see the problem clearer. wrong display for banking right: + | correct display for banking right: +-- The "+" sign is the origin where the target locator vector starts.

Share this post


Link to post
Share on other sites
Can you just restrict the test to the ground plane, and have your target locator respond to that? Let's say the ground plane is xy. Then:

Vector2 planePos(plane.pos.x, plane.pos.y);
Vector2 planeDir(plane.dir.x, plane.dir.y);
Vector2 targetPos(target.pos.x, target.pos.y);
Vector2 diff = targetPos - planePos;
float dot = planeDir.PerpDot(diff); // perp dot is a.x * -b.y + a.y * b.x
if (dot < 0.0f)
// Target indicator points left
else if (dot > 0.0f)
// Target indicator points right
else
// Target indicator off (unlikely)

Anyway, that's based on my understanding of the problem, but I may not be getting it exactly.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this