A Point3.T is a point in 3-space. It is represented as a record
with three components, x, y, and z, all holding real values.
INTERFACEPoint3 ; TYPE T = RECORD x,y,z : REAL; END; CONST Origin = T {0.0, 0.0, 0.0}; Min = T {FIRST(REAL), FIRST(REAL), FIRST(REAL)}; Max = T {LAST (REAL), LAST (REAL), LAST (REAL)};
Originis the origin of the coordinate system.MinandMaxare used in bounding box calculations to represent imaginary smallest and largest points.
PROCEDURE Plus (a, b : T) : T;
Plus(a,b)returns the sum of the pointsaandb.
PROCEDURE Minus (a, b : T) : T;
Minus(a,b)returns the difference betweenaandb.
PROCEDURE TimesScalar (a : T; x : REAL) : T;
TimesScalar(a,s)returnsawith each component multiplied with the scalar values.
PROCEDURE MidPoint (a, b : T) : T;
MidPoint(a,b)returns the point in the middle betweenaandb.
PROCEDURE Distance (a, b : T) : REAL;
Distance(a,b)returns the distance betweenaandb.
PROCEDURE ToText (a : T) : TEXT;
ToText(a)returns a textual representation ofa; for example,ToText(T{2.0,3.0,5.0})returns the text(2.0,3.0,5.0).
The remaining operations interpret their arguments as vectors, not as points. The vector
a is the vector going from the origin to point a.
PROCEDURE Length (a : T) : REAL;
Length(a)returns the length of the vectora.
PROCEDURE DotProduct (a, b : T) : REAL;
Returns the dot product ofaandb. See [Foley] p. 1094ff for an explanation of the geometric significance of dot products.
PROCEDURE CrossProduct (a, b : T) : T;
Returns the cross product ofaandb. See [Foley] p. 1104ff for an explanation of the geometric significance of cross products. One important property is that $a \times b$ is orthogonal to the plane described by the vectorsaandb.
PROCEDURE OrthoVector (a : T) : T;
Returns a unit vector which is orthogonal ton. There are infinitely many such vectors,OrthoVectorwill return one of them.
PROCEDURE ScaleToLen (a : T; len : REAL) : T;
Returns a vector parallel toawith lengthlen.
END Point3.