File: SVAngle.mesa
Last edited by Bier on June 1, 1984 4:28:17 pm PDT
Author: Eric Bier on June 26, 1984 11:12:29 am PDT
Contents: Solidviews requires a precise set of angle operations defined with angle "theta" in the range -180 < theta <= 180. "theta" is an absolute angle (ie a position around the circle measured from the positive x axis). Given two positions angles T1 and T2 we can find the incremental clockwise angle CT between them or the incremental counter-clockwise angle CCT where -360 < CT <= 0 and 0 <= CCT < 360. When we add two angles, we are adding an incremental angle to a position angle to get a new position angle. We subtract two position angles to get an incremental angle. All angles are in degrees.
SVAngle: DEFINITIONS =
BEGIN
Normalize: PROC [anyRange: REAL] RETURNS [range180: REAL];
Takes an angle in degrees and puts it in 180 < theta <= 180 form.
Add: PROC [position, increment: REAL] RETURNS [finalPosition: REAL];
All angles in degrees
ClockwiseAngle: PROC [fromPosition, toPostion: REAL] RETURNS [increment: REAL];
All angles in degrees. -360 < increment <= 0
CounterClockwiseAngle: PROC [fromPosition, toPostion: REAL] RETURNS [increment: REAL];
All angles in degrees. 0 <= increment < 360.
For example, if the clockwise angle is -90, the counter-clockwise angle will be 270.
ShortestDifference: PROC [position1, position2: REAL] RETURNS [pos1MinusPos2: REAL];
All angles in degrees. RETURNS ClockwiseAngle or CounterClockwiseAngle. Whichever is smaller. -180< pos1MinusPos2 <= 180.
Scale: PROC [angle: REAL, scalar: REAL] RETURNS [angleTimesScalar: REAL];
All angles in degrees. Think of angle as the increment from 0 degrees to angle degrees. Scale this and normalize.
ArcTan: PROC [numerator, denominator: REAL] RETURNS [degrees: REAL];
Has the effect of calling RealFns.ArcTanDegrees and normalizing the result.
END.