Difference between revisions of "Trigonometry Functions"

Jump to navigation Jump to search
2,417 bytes added ,  11:17, 9 May 2006
no edit summary
imported>Dysesothymteric
imported>Bifmadeinsabbioni
Line 123: Line 123:




== Taylor Series Variant 3 ==
The idea here is to approximate sin(z) and cos(z) with taylor. Since taylor works best with values close to 0,
I think it's a good idea to use sin and cos periodicity as many times as possible. then I used taylor to approximate the functions.
ScriptName Sin(Z)
set Angolo to AngleZ ; Angolo is the angle of which we want to calculate the sin
set Sign to 1 ; it's the sign adjustment of the result
if (Angolo > 180)&& (Angolo <=360) ; if 180<=z<=360 sin(z) = -sin(z-180)
set Sign to Sign * (-1)
set Angolo to (Angolo - 180)
endif
 
if (Angolo > 90)&&(Angolo <=180) ; if 90<=z<=180 sin (z) = sin (180-z)
set Angolo to (180 - angolo)
endif
if (Angolo >45)&&(Angolo <=90) ; if 45<z<90 sin(z) = cos(90-z)
set Angle to (90 - Angolo)
      set Angle to (3.14159265 * Angle / 180) ;now in radiants
set X2 to Angle * Angle
set X4 to X2 * X2
set X6 to X4 * X2
set X8 to X4 * X4
set SinZ to (1 - X2 / 2 + X4 / 24 - X6 / 720 + X8 / 40320)
set SinZ to SinZ*Sign
endif
if (Angolo>=0)&&(Angolo<=45)
set Angle to Angolo
      set Angle to (3.14159265 * Angle / 180) ;now in radiants
set X to Angle
set X3 to X*X*X
set X5 to X3*X*X
set X7 to X3*X3*X
set X9 to X3*X3*X3
set SinZ to (X - X3 / 6 + X5 / 120 - X7 / 5040 + X9 / 362880)
set SinZ to SinZ*Sign
endif
ScriptName Cos(Z)
set Angolo to AngleZ ; Angolo is the angle of which we want to calculate the cos
set Sign to 1 ; it's the sign adjustment of the result
 
if (Angolo > 180)&& (Angolo <=360) ; if 180<=z<=360 cos(z) = -cos(z-180)
set Sign to Sign * (-1)
set Angolo to (Angolo - 180)
endif
if (Angolo > 90)&&(Angolo <=180)  ; if 90<=z<=180 cos (z) = -cos(180-z)
set Angolo to (180 - Angolo)
set Sign to Sign * (-1)
endif
if (Angolo >45)&&(Angolo <=90) if 45<z<90 cos(z) = sin(90-z)
set Angle to (90 - Angolo)
      set Angle to (3.14159265 * Angle / 180) ;now in radiants
set X to Angle
set X3 to X*X*X
set X5 to X3*X*X
set X7 to X3*X3*X
set X9 to X3*X3*X3
set CosZ to (X - X3 / 6 + X5 / 120 - X7 / 5040 + X9 / 362880)
set CosZ to CosZ * Sign
endif
if (Angolo>=0)&&(Angolo<=45)
set Angle to Angolo
      set Angle to (3.14159265 * Angle / 180) ;now in radiants
set X2 to Angle * Angle
set X4 to X2 * X2
set X6 to X4 * X2
set X8 to X4 * X4
set CosZ to (1 - X2 / 2 + X4 / 24 - X6 / 720 + X8 / 40320)
set CosZ to CosZ * Sign
endif




Navigation menu