size : 6883 uploaded_on : Sat Jun 20 00:00:00 1998 modified_on : Wed Dec 8 14:03:37 1999 title : Missing trigonometric functions org_filename : Calc.pas author : Unknown authoremail : description : Trigonometric, hyperbolic, logarithmic, power and root functions keywords : tested : Borland Pascal 7.0 submitted_by : The CKB Crew submitted_by_email : ckb@netalive.org uploaded_by : nobody modified_by : nobody owner : nobody lang : pas file-type : text/plain category : pascal-alg-maths __END_OF_HEADER__ {$O+} { F i l e I n f o r m a t i o n * DESCRIPTION Supplies missing trigonometric functions for Turbo Pascal 5.5. Also provides hyperbolic, logarithmic, power, and root functions. All trig functions accessibile by radians, decimal degrees, degrees-minutes-seconds and a global DegreeType. } unit PTD_Calc; (* PTD_Calc - Supplies missing trigonometric functions for Turbo Pascal 5.5 * Also provides hyperbolic, logarithmic, power, and root functions. * All trig functions accessible by radians, decimal degrees, * degrees-minutes-seconds, and a global DegreeType. Conversions * between these are supplied. * *) interface type DegreeType = record Degrees, Minutes, Seconds : real; end; const Infinity = 9.9999999999E+37; { Radians } { sin, cos, and arctan are predefined } function Tan( Radians : real ) : real; function ArcSin( InValue : real ) : real; function ArcCos( InValue : real ) : real; { Degrees, expressed as a real number } function DegreesToRadians( Degrees : real ) : real; function RadiansToDegrees( Radians : real ) : real; function Sin_Degree( Degrees : real ) : real; function Cos_Degree( Degrees : real ) : real; function Tan_Degree( Degrees : real ) : real; function ArcSin_Degree( Degrees : real ) : real; function ArcCos_Degree( Degrees : real ) : real; function ArcTan_Degree( Degrees : real ) : real; { Degrees, in Degrees, Minutes, and Seconds, as real numbers } function DegreePartsToDegrees( Degrees, Minutes, Seconds : real ) : real; function DegreePartsToRadians( Degrees, Minutes, Seconds : real ) : real; procedure DegreesToDegreeParts( DegreesIn : real; var Degrees, Minutes, Seconds : real ); procedure RadiansToDegreeParts( Radians : real; var Degrees, Minutes, Seconds : real ); function Sin_DegreeParts( Degrees, Minutes, Seconds : real ) : real; function Cos_DegreeParts( Degrees, Minutes, Seconds : real ) : real; function Tan_DegreeParts( Degrees, Minutes, Seconds : real ) : real; function ArcSin_DegreeParts( Degrees, Minutes, Seconds : real ) : real; function ArcCos_DegreeParts( Degrees, Minutes, Seconds : real ) : real; function ArcTan_DegreeParts( Degrees, Minutes, Seconds : real ) : real; { Degrees, expressed as DegreeType ( reals in record ) } function DegreeTypeToDegrees( DegreeVar : DegreeType ) : real; function DegreeTypeToRadians( DegreeVar : DegreeType ) : real; procedure DegreeTypeToDegreeParts( DegreeVar : DegreeType; var Degrees, Minutes, Seconds : real ); procedure DegreesToDegreeType( Degrees : real; var DegreeVar : DegreeType ); procedure RadiansToDegreeType( Radians : real; var DegreeVar : DegreeType ); procedure DegreePartsToDegreeType( Degrees, Minutes, Seconds : real; var DegreeVar : DegreeType ); function Sin_DegreeType( DegreeVar : DegreeType ) : real; function Cos_DegreeType( DegreeVar : DegreeType ) : real; function Tan_DegreeType( DegreeVar : DegreeType ) : real; function ArcSin_DegreeType( DegreeVar : DegreeType ) : real; function ArcCos_DegreeType( DegreeVar : DegreeType ) : real; function ArcTan_DegreeType( DegreeVar : DegreeType ) : real; { Hyperbolic functions } function Sinh( Invalue : real ) : real; function Cosh( Invalue : real ) : real; function Tanh( Invalue : real ) : real; function Coth( Invalue : real ) : real; function Sech( Invalue : real ) : real; function Csch( Invalue : real ) : real; function ArcSinh( Invalue : real ) : real; function ArcCosh( Invalue : real ) : real; function ArcTanh( Invalue : real ) : real; function ArcCoth( Invalue : real ) : real; function ArcSech( Invalue : real ) : real; function ArcCsch( Invalue : real ) : real; { Logarithms, Powers, and Roots } { e to the x is exp() } { natural log is ln() } function Log10( InNumber : real ) : real; function Log( Base, InNumber : real ) : real; { log of any base } function Power( InNumber, Exponent : real ) : real; function Root( InNumber, TheRoot : real ) : real; {----------------------------------------------------------------------} implementation const RadiansPerDegree = 0.017453292520; DegreesPerRadian = 57.295779513; MinutesPerDegree = 60.0; SecondsPerDegree = 3600.0; SecondsPerMinute = 60.0; LnOf10 = 2.3025850930; {-----------} { Radians } {-----------} { sin, cos, and arctan are predefined } function Tan { ( Radians : real ) : real }; { note: returns Infinity where appropriate } var CosineVal : real; TangentVal : real; begin CosineVal := cos( Radians ); if CosineVal = 0.0 then Tan := Infinity else begin TangentVal := sin( Radians ) / CosineVal; if ( TangentVal < -Infinity ) or ( TangentVal > Infinity ) then Tan := Infinity else Tan := TangentVal; end; end; function ArcSin{ ( InValue : real ) : real }; { notes: 1) exceeding input range of -1 through +1 will cause runtime error } { 2) only returns principal values } { ( -pi/2 through pi/2 radians ) ( -90 through +90 degrees ) } begin if abs( InValue ) = 1.0 then ArcSin := pi / 2.0 else ArcSin := arctan( InValue / sqrt( 1 - InValue * InValue ) ); end; function ArcCos{ ( InValue : real ) : real }; { notes: 1) exceeding input range of -1 through +1 will cause runtime error } { 2) only returns principal values } { ( 0 through pi radians ) ( 0 through +180 degrees ) } var Result : real; begin if InValue = 0.0 then ArcCos := pi / 2.0 else begin Result := arctan( sqrt( 1 - InValue * InValue ) / InValue ); if InValue < 0.0 then ArcCos := Result + pi else ArcCos := Result; end; end; {---------------------------------------} { Degrees, expressed as a real number } {---------------------------------------} function DegreesToRadians{ ( Degrees : real ) : real }; begin DegreesToRadians := Degrees * RadiansPerDegree; end; function RadiansToDegrees{ ( Radians : real ) : real }; begin RadiansToDegrees := Radians * DegreesPerRadian; end; function Sin_Degree{ ( Degrees : real ) : real }; begin Sin_Degree := sin( DegreesToRadians( Degrees ) ); end; function Cos_Degree{ ( Degrees : real ) : real }; begin Cos_Degree := cos( DegreesToRadians( Degrees ) ); end; function Tan_Degree{ ( Degrees : real ) : real }; begin Tan_Degree := Tan( DegreesToRadians( Degrees ) ); <ORIGINAL MESSAGE OVER 200 LINES, SPLIT IN 2 OR MORE> ============================================================================== BBS: «« The Information and Technology Exchan To: JEFFREY HUNTSMAN Date: 11-27─91 (09:08) From: FLOOR NAAIJKENS Number: 3163 [101] PASCAL Subj: CALC (1) <CONT> Status: Publ