- Joined
- Mar 28, 2008
- Messages
- 671
- Reaction score
- 32
- Points
- 43
Hello,
I need to get the relative x / y distance (in m) to a target surface point.
Relative means, that if the point is directly in front, then x is 0 and y = distance.
If the point is on the left hand, x = -distance, y = 0 and so on...
But this code will not work so whats wrong with it?
I need to get the relative x / y distance (in m) to a target surface point.
Relative means, that if the point is directly in front, then x is 0 and y = distance.
If the point is on the left hand, x = -distance, y = 0 and so on...
But this code will not work so whats wrong with it?
Code:
{
VECTOR3 v3Loc, v3Rel;
double r = oapiGetSize(v->GetGravityRef()); // v = oapiGetFocusInterface()
//targetPoint => Position of base pad 4 of brighton beach
//targetPoint.x = -0.58284397722227876; // -33.34 (long)
//targetPoint.y = 0.71729529872535591; // 41.10 (lat)
OBJHANDLE gb = v->GetGravityRef();
double r_g = oapiGetSize(gb);
double r_deg = oapiOrthodome(pos.x,pos.y,targetPoint.x, targetPoint.y); // pos => position of focus vessel
double r_m = r_deg * r_g; //Distance to position in m (works fine)
oapiEquToLocal(v->GetHandle(), targetPoint.x, targetPoint.y, r_m, &v3Loc);
v->Local2Rel(v3Loc, v3Rel);
sprintf(oapiDebugString(),"Rel x: %f Rel y: %f Rel z: %f distanceToBasePad: %f",v3Rel.x, v3Rel.y, v3Rel.z, r_m);
}
Last edited: