Difference between revisions of "ESM Math Library"
Jump to navigation
Jump to search
added stage 6 & 7 - 2 functions to normalize angles - STAGE 6 IS A REAL LOOP! :)
imported>Galsiah |
imported>JustTim (added stage 6 & 7 - 2 functions to normalize angles - STAGE 6 IS A REAL LOOP! :)) |
||
|
;S5 FUNCTION sqrt
float sqr
;S6 FUNCTION NormalizeAngle360
;S7 FUNCTION NormalizeAngle180
;S10 FUNCTION Hypotenuse
set f.fin1 to myVarForInput
setStage f 5
set myResult to f.fout</pre>
=== Stage 6: Normalize Angle (0 till 360) ===
Takes an Angle and normalizes it to a range from 0 to 360 degrees.
This is a functional loop!
Code for the Stage Result Script:
<pre>;FUNCTION float NormalizeAngle360(float Angle)
if (f.fin1 >= 0) && (f.fin1 <= 360)
else
else
endif▼
;CALL float NormalizeAngle360(float angle)
setStage f 6
endif</pre>▼
Usage in another script:
<pre>;CALL float NormalizeAngle360(float angle)
set f.fin1 to myVarForAngle
setStage f 6
set myResult to f.fout</pre>
=== Stage 7: Normalize Angle (-180 till 180) ===
Takes an Angle and normalizes it to a range from -180 to 180 degrees.
Code for the Stage Result Script:
<pre>;FUNCTION float NormalizeAngle180(float Angle)
if (f.fin1 < 0) || (f.fin1 > 360)
;CALL float NormalizeAngle360(float Angle)
setStage f 6
else
endif▼
endif</pre>
Usage in another script:
<pre>;CALL float NormalizeAngle180(float angle)
set f.fin1 to myVarForAngle
setStage f 7
set myResult to f.fout</pre>
;Taylor Series Variant 1 - script by Galerion
;CALL float NormalizeAngle180(float Angle)
▲set f.ang to f.fin1
setStage f 7
▲ set f.ang to (f.ang + 360)
▲elseif f.ang > 180
▲ set f.ang to (f.ang - 360)
▲endif
;approximate
set f.fout to f.sin
if f.cos == 0
endif
set f.fout2 to f.cos
set f.fout3 to (f.sin/f.cos) ;tan</pre>
;Taylor Series Variant 2 - script by JOG
;CALL float NormalizeAngle180(float Angle)
▲set f.ang to f.fin1
setStage f 7
▲endif
set f.t1 to (f.ang*f.degToRad)
set f.fout to f.sin
if f.cos == 0
endif
set f.fout2 to f.cos
set f.fout3 to f.sin/f.cos ;tan</pre>
;script by Galsiah
;CALL float NormalizeAngle360(float Angle)
▲set f.ang to f.fin1
setStage f 6
▲if f.ang < 0
▲ set f.ang to (f.ang - 360)
▲endif
set f.n to 1
Code for the Stage Result Script:
<pre>;FUNCTION float getAngle(float x, float y)
if f.fin1 == 0
endif
if f.fin2 == 0
set f.fin2 to 0.001
endif
set f.tan to (f.fin1/f.fin2)
| |||