PEAlgebra.mesa
Written by Darlene Plebon on August 16, 1983 1:36 pm
Useful linear algebra routines.
DIRECTORY
PETypes;
PEAlgebra: CEDAR DEFINITIONS =
BEGIN OPEN PETypes;
Sqr: PUBLIC PROCEDURE [number: REAL] RETURNS [squared: REAL] = INLINE {
RETURN[number * number];
};
DistanceSquared: PUBLIC PROCEDURE [a, b: Point] RETURNS [d: REAL] = INLINE {
RETURN [Sqr[a.x - b.x] + Sqr[a.y - b.y]];
};
ClosestPointOnLineSegment: PROCEDURE [point, p0, p1: Point] RETURNS [closestPoint: Point];
This routine returns the point on the line segment [p0,p1] which is closest to the specified point.
Projection: PROCEDURE [point, p0, p1: Point] RETURNS [colinearPoint: Point];
This procedure projects the specified point onto the line defined by p0 and p1. The returned point is colinear with p0 and p1.
Intersection: PROCEDURE [line1A, line1B, line2A, line2B: Point] RETURNS [intersecting: BOOLEAN, p: Point];
This routine determines the intersection of two lines, each of which is defined by two points on the line. This routine returns an indication of whether the two lines intersect, along with the point of intersection.
END.