File: GGVector.mesa
Last edited by Bier on June 4, 1985 6:08:43 pm PDT
Author: Eric Bier on July 31, 1986 10:27:17 pm PDT
Contents: Routines for manipulating vectors in two dimensions
Pier, December 6, 1985 10:01:49 am PST
DIRECTORY
GGBasicTypes;
GGVector: CEDAR DEFINITIONS =
BEGIN
Point: TYPE = GGBasicTypes.Point;
Edge: TYPE = GGBasicTypes.Edge;
Vector: TYPE = GGBasicTypes.Vector;
VectorFromAngle: PROC [angle: REAL] RETURNS [vector: Vector];
angle must be in degrees in the range: -180 < angle <= 180.
vector is a unit vector.
VectorPlusAngle: PROC [v: Vector, degrees: REAL] RETURNS [rotatedV: Vector];
AngleFromVector: PROC [v: Vector] RETURNS [position: REAL];
AngleCCWBetweenVectors: PROC [v1, v2: Vector] RETURNS [difference: REAL];
difference will be in: 0 <= difference < 360. A clockwise angle
AngleCWBetweenVectors: PROC [v1, v2: Vector] RETURNS [difference: REAL];
difference will be in: 0 <= difference < 360. A counter-clockwise angle
SmallestAngleBetweenVectors: PROC [v1, v2: Vector] RETURNS [difference: REAL];
All angles in degrees. RETURNS ClockwiseAngle or CounterClockwiseAngle. Whichever is smaller. -180< difference <= 180.
Add: PROC [v1, v2: Vector] RETURNS [v1PlusV2: Vector];
Sub: PROC [v1, v2: Vector] RETURNS [v1MinusV2: Vector];
Scale: PROC [v: Vector, s: REAL] RETURNS [vTimesS: Vector];
Normalize: PROC [v: Vector] RETURNS [normV: Vector];
Negate: PROC [v: Vector] RETURNS [negV: Vector];
ElementwiseProduct: PROC [v1, v2: Vector] RETURNS [v1Timesv2: Vector];
DotProduct: PROC [v1, v2: Vector] RETURNS [scalar: REAL];
CrossProductScalar: PROC [v1, v2: Vector] RETURNS [scalar: REAL];
Returns the signed magnitude of the cross product.
Magnitude: PROC [v: Vector] RETURNS [mag: REAL];
Distance: PROC [p1, p2: Point] RETURNS [dist: REAL];
MagnitudeSquared: PROC [v: Vector] RETURNS [magSquared: REAL];
DistanceSquared: PROC [p1, p2: Point] RETURNS [distSquared: REAL];
VectorFromPoints: PROC [tail, head: Point] RETURNS [vector: Vector];
RightNormalOfEdge: PROC [edge: Edge] RETURNS [normal: Vector];
LeftNormalOfEdge: PROC [edge: Edge] RETURNS [normal: Vector];
END.