DistanceToLine:
PUBLIC
PROC [p: Pair, line2d: Triple]
RETURNS [
REAL] ~ {
RETURN[p.x*line2d.x+p.y*line2d.y+line2d.z];
};
IntersectTwoLines:
PUBLIC
PROC [line0, line1: Triple]
RETURNS [Pair] ~ {
If cross.z = 0, then the lines meet at infinity in the (cross.x, cross.y) direction;
otherwise, the lines meet at (cross.x/cross.z, cross.y/cross.z);
cross: Triple ¬ [line0.y*line1.z-line0.z*line1.y,line0.z*line1.x-line0.x*line1.z,line0.x*line1.y-line0.y*line1.x];
IF cross.z = 0.0 THEN ERROR;
RETURN[[cross.x/cross.z, cross.y/cross.z]];
};