Fix LOS clearance: use real bezier apex, not control point
This commit is contained in:
parent
ae6d50f1a9
commit
b8380e3e0f
1 changed files with 5 additions and 4 deletions
|
|
@ -279,12 +279,13 @@
|
|||
const h2px = s.values.h2 * pxPerM;
|
||||
const yA = groundY - h1px, yB = groundY - h2px;
|
||||
|
||||
// signal line, compute clearance over hill apex
|
||||
// signal line, compute clearance over the hill's actual apex. The hill is drawn
|
||||
// as a quadratic bezier from (hx-hw, groundY) to (hx+hw, groundY) with control
|
||||
// at (hx, groundY - hh*2). At t=0.5 the curve reaches groundY - hh, which is
|
||||
// the real visual top. Using the control-point y here would over-count by 2x.
|
||||
const t = (hx - xA) / (xB - xA);
|
||||
const yOnRay = yA + (yB - yA) * t;
|
||||
const hillTop = groundY - hh * 2;
|
||||
const clearance = hillTop - yOnRay; // negative = obstructed... actually no: smaller y = higher. yOnRay < hillTop (more negative offset) means ray is ABOVE hill => clearance positive.
|
||||
// With screen coords (y down), ray above hill means yOnRay < hillTop. Clearance in meters = (hillTop - yOnRay)/pxPerM. Positive when ray above hill.
|
||||
const hillTop = groundY - hh;
|
||||
const clearanceM = (hillTop - yOnRay) / pxPerM;
|
||||
const blocked = clearanceM < 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue