Blitz3D+ Command Reference

ASin# ( float# )

Parameters

float - a sine value; must be in the range -1 to 1

Description

Returns the angle, in degrees, whose sine is the given value.

ASin is the inverse of Sin, and it answers in the range -90 to +90 degrees. That is the half of the circle where sine is unambiguous: sine alone cannot tell 30 degrees from 150 degrees, so ASin always picks the one nearest zero.

Because of that limit, ASin is best for "how steep is this" questions - the pitch of a slope, how far a ramp climbs over a given distance - rather than for working out a full heading. When you need all 360 degrees, use ATan2 instead, which looks at both components and gets the quadrant right.

Values outside -1 to 1 return NaN (not a number), so clamp anything that comes out of a division before you feed it in.

See also: Sin, ACos, ATan, ATan2, Pi.

Example

; ASin Example
; ------------

; ASin is the inverse of Sin: given a sine value between -1.0 and 1.0,
; it returns the matching angle in DEGREES, from -90 up to +90.

Print "     value  ASin(value)"
Print "-----------------------"

For n=-4 To 4
    v#=n/4.0
    Print RSet(v,10)+RSet(ASin(v),12)
Next

Print ""

; Feeding a sine back through ASin recovers the original angle
Print "Sin(30)       = "+Sin(30)
Print "ASin(Sin(30)) = "+ASin(Sin(30))

Print ""
Print "Press any key to close the example"
WaitKey

End

Index