Complex.mesa
Copyright Ó 1985, 1989, 1992 by Xerox Corporation. All rights reserved.
Last edited by Michael Plass, January 4, 1984 11:53 am
Written by Michael Plass, 28-Sep-81
Tim Diebert May 20, 1985 2:08:04 pm PDT
Doug Wyatt, September 12, 1989 5:01:52 pm PDT
DIRECTORY
Vector2 USING [VEC];
Complex: CEDAR DEFINITIONS =
BEGIN
Add:
PROCEDURE [a:
VEC, b:
VEC]
RETURNS [
VEC] =
INLINE
{RETURN[[a.x+b.x,a.y+b.y]]}; -- same as vector sum
Sub:
PROCEDURE [a:
VEC, b:
VEC]
RETURNS [
VEC] =
INLINE
{RETURN[[a.x-b.x,a.y-b.y]]}; -- same as vector difference
Neg:
PROCEDURE [a:
VEC]
RETURNS [
VEC] =
INLINE
{RETURN[[-a.x,-a.y]]}; -- same as vector complement
Mul:
PROCEDURE [a:
VEC, b:
VEC]
RETURNS [
VEC];
-- complex product
Div:
PROCEDURE [a:
VEC, b:
VEC]
RETURNS [
VEC]
;
-- complex quotient
Conjugate:
PROCEDURE [a:
VEC]
RETURNS [
VEC] =
INLINE
{RETURN[[a.x,-a.y]]}; -- complex conjugate
AlmostEqual: PROCEDURE [a: VEC, b: VEC, mag:[-126..0] ¬ -20] RETURNS [BOOLEAN];
FromPolar:
PROCEDURE [r:
REAL, radians:
REAL]
RETURNS [
VEC];
Abs:
PROCEDURE [a:
VEC]
RETURNS [
REAL];
-- same as Vector.Mag
SqrAbs:
PROCEDURE [a:
VEC]
RETURNS [
REAL] =
INLINE
{RETURN[a.x*a.x+a.y*a.y]}; -- good for checking tolerance
Arg:
PROCEDURE [a:
VEC]
RETURNS [
REAL];
returns the angle from the x axis to a, in radians.
Exp:
PROCEDURE [a:
VEC]
RETURNS [
VEC];
complex exponential function
Ln:
PROCEDURE [a:
VEC]
RETURNS [
VEC];
complex natural logarithm
Sqr:
PROCEDURE [a:
VEC]
RETURNS [
VEC];
-- like Mul[a,a]
SqRt:
PROCEDURE [a:
VEC]
RETURNS [
VEC];
-- complex square root
END.