Ron Jensen wrote:
> is where you're looking from...  So
>
> ((x-offset-m - target-x-offset-m)^2 + (y-offset-m - target-y-offset-m)^2 + 
> (z-offset-m - target-z-offset-m)^2 ) ^0.5
>
>   
Thanks Ron, unfortunately your formula doesn't seem right, I don't think 
it's giving me what I want, or I have made a flaw in my implementation 
perhaps (but looking at the offset values, in most exterior views they 
are basically zero anyway, so pretty sure it's just not the numbers I'm 
looking for).

var distance_to_camera = func {
    var model_x = getprop('/sim/current-view/target-x-offset-m');
    var model_y = getprop('/sim/current-view/target-y-offset-m');
    var model_z = getprop('/sim/current-view/target-z-offset-m');

    var me_x    = getprop('/sim/current-view/x-offset-m');
    var me_y    = getprop('/sim/current-view/y-offset-m');
    var me_z    = getprop('/sim/current-view/z-offset-m');

    var x_diff = me_x - model_x;
    var y_diff = me_y - model_y;
    var z_diff = me_z - model_z;
   
    return math.sqrt(
               (x_diff * x_diff)
      +    (y_diff * y_diff)
          +    (z_diff * z_diff) );              
}

To clarify, imagine you are standing in the tower, looking at an 
aircraft, I want to know the straight line distance between your 
eyeball, and the aircraft (for some reference point on the aircraft, 
doesn't matter what).

---
James Sleeman

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to