Center line of a conveyor
64-bitThe length of a straight, zoned, inclined or curved conveyor and the point and heading at a distance along it.
incline: L = √(length² + rise²); curve: L = r × |angle|, point = (r sin θ, ± r (1 − cos θ)), θ = s ÷ r
The curve uses 1 − cos θ, which loses digits for a very small θ; the sideways offset it gives is itself very small there. The angle is converted with π ÷ 180 in 64-bit.
export function localPath(kind, p) {
switch (kind) {
case 'conveyor': case 'agv-path': return { length: p.length, at: (s) => ({ p: [s, 0, 0], h: 0 }) };
case 'zone': { const L = p.zones * p.zoneLength; return { length: L, at: (s) => ({ p: [s, 0, 0], h: 0 }) }; }
case 'incline': {
const L = Math.hypot(p.length, p.rise);
return { length: L, at: (s) => ({ p: [(s / L) * p.length, 0, (s / L) * p.rise], h: 0 }) };
}
case 'curve': {
const r = p.radius, a = p.angle * DEG, sg = a >= 0 ? 1 : -1, L = r * Math.abs(a);
return { length: L, at: (s) => { const th = s / r; return { p: [r * Math.sin(th), sg * r * (1 - Math.cos(th)), 0], h: (sg * th) / DEG }; } };
}
}
return null;
}