How to use my TRIG Library Since GNU treats inline functions slightly differently to CW the 1st thing to note is that if you are using GNU change the line in trig.h that reads //#define GNU_C to #define GNU_C the makefile is for the GNU C trigtest program the trig.mcp file is for the CW trigtest program The angles are defined as positive integers 0-4095 clockwise from due north 0 degrees = 0 PSX units 90 degrees = 1024 PSX units 180 degrees = 2048 PSX units 270 degrees = 3096 PSX units (same as -90 degrees) 360 degrees = 4096 PSX units The function values are in 12bit fixed point. so 1.0 = 4096 (this is #defined in libps.h as ONE) 0.5 = 2048 etc. Function Descriptions Conversion int Deg2PSX(int DegAngle) - converts from angle in degrees to angle in PSX. Returns angle in PSX units int PSX2Deg(int PSXAngle) - converts from angle in PSX units to angle in degrees. Returns angle in degrees PSX unit functions int TanP(int PSXAngle) - returns Tan of PSX angle. Return Value is 12 bit fixed point int SinP(int PSXAngle) - returns Sin of PSX angle. Return Value is 12 bit fixed point int CosP(int PSXAngle) - returns Cos of PSX angle. Return Value is 12 bit fixed point int ATanP(int X) - returns Atan of X (X is in 12 bit fixed point, angle returned in PSX units) int ASinP(int X) - returns Asin of X (X is in 12 bit fixed point, angle returned in PSX units) int ACosP(int X) - returns Acos of X (X is in 12 bit fixed point, angle returned in PSX units) Degree functions int TanD(int DegAngle) - returns Tan of angle. Return Value is 12 bit fixed point int SinD(int DegAngle) - returns Sin of angle. Return Value is 12 bit fixed point int CosD(int DegAngle) - returns Cos of angle. Return Value is 12 bit fixed point int ATanD(int X) - returns Atan of X (X is in 12 bit fixed point, angle returned in degrees) int ASinD(int X) - returns Asin of X (X is in 12 bit fixed point, angle returned in degrees) int ACosD(int X) - returns Acos of X (X is in 12 bit fixed point, angle returned in degrees) Misc u_long ISqrt(u_long X) - returns integer square root of X TrigTest(void) - tests all of the above functions Usage | dx / | / dy | / |A/ |/ to find the angle A of the above triangle val=(dx*4096)/dy; // alternatively for better readability val=(dx*ONE)/dy A=ATanP(val); // A is angle in PSX units A=ATanD(val); // A is angle in degrees Similarly knowing the angle A and length dy find dx A in degrees val=TanD(A); dx=(val*dy)/ONE; A in PSX units val=TanP(A); dx=(val*dy)/ONE; Any questions feedback appreciated Nick Slaven NickSlaven@compuserve.com