Vector2Impl.mesa
Doug Wyatt, July 3, 1984 12:28:38 pm PDT
DIRECTORY
Real USING [SqRt],
Vector2;
Vector2Impl: CEDAR PROGRAM
IMPORTS Real, Vector2
EXPORTS Vector2
~ BEGIN OPEN Vector2;
Add:
PUBLIC
PROC[a, b:
VEC]
RETURNS[
VEC] ~ {
RETURN[InlineAdd[a, b]] };
Vector sum, a+b.
Sub:
PUBLIC
PROC[a, b:
VEC]
RETURNS[
VEC] ~ {
RETURN[InlineSub[a, b]] };
Vector difference, a-b.
Neg:
PUBLIC
PROC[a:
VEC]
RETURNS[
VEC] ~ {
RETURN[InlineNeg[a]] };
Vector complement, -a.
Mul:
PUBLIC
PROC[a:
VEC, s:
REAL]
RETURNS[
VEC] ~ {
RETURN[InlineMul[a, s]] };
Product of vector a and scalar s.
Div:
PUBLIC
PROC[a:
VEC, s:
REAL]
RETURNS[
VEC] ~ {
RETURN[InlineDiv[a, s]] };
Equivalent to Mul[a, 1/s].
SqrMag:
PUBLIC
PROC[a:
VEC]
RETURNS[
REAL] ~ {
RETURN[InlineSqrMag[a]] };
Square of the magnitude of a.
Mag:
PUBLIC
PROC[a:
VEC]
RETURNS[
REAL] ~ {
RETURN[InlineMag[a]] };
Magnitude of a.
Dot:
PUBLIC
PROC[a, b:
VEC]
RETURNS[
REAL] ~ {
RETURN[InlineDot[a, b]] };
Dot (inner) product of a and b.
Cross:
PUBLIC
PROC[a, b:
VEC]
RETURNS[
REAL] ~ {
RETURN[InlineCross[a, b]] };
Magnitude of the cross (outer) product of a and b.
Unit:
PUBLIC
PROC[a:
VEC]
RETURNS[
VEC] ~ {
RETURN[InlineUnit[a]] };
Unit vector in the direction of a.
Normal:
PUBLIC
PROC[a:
VEC]
RETURNS[
VEC] ~ {
RETURN[InlineNormal[a]] };
Vector normal to a.
END.