Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Formula
#11
I suspect that Chris expects the arguments to asin and sin to be in degrees
Reply
#12
When you take the _Asin(sin(a)) I expected it to return the angle a.

It is returning everything between 0 and +|- 90 degrees, it may be right I never use _Asin().

OK
Code: (Select All)
? sin(_pi/4), sin(_pi(3/4))
b = b + ...
Reply
#13
(10-02-2024, 10:19 PM)bplus Wrote: When you take the _Asin(sin(a)) I expected it to return the angle a.

It is returning everything between 0 and +|- 90 degrees, it may be right I never use _Asin().

OK
Code: (Select All)
? sin(_pi/4), sin(_pi(3/4))   

It won't though.  Here's why:

SIN (30) = 0.5
SIN (150) = 0.5

So _ASIN(0.5) is going to tell you it's 150... How?

Same SIN value, same ASIN angle returned.
Reply
#14
(10-02-2024, 10:19 PM)bplus Wrote: When you take the _Asin(sin(a)) I expected it to return the angle a.
_asin is bound to -pi/2 < a < pi/2 , so any higher value will just roll over, I guess why they call it "arc" sine
Reply
#15
"How?"

Don't tell, offer the 2 choices:
Code: (Select All)
Print ArcSinDegrees$(Sin(_Pi / 4))
Print ArcSinDegrees$(Sin(_Pi(3 / 4)))
Print ArcSinDegrees$(Sin(_Pi(5 / 4)))
Print ArcSinDegrees$(Sin(_Pi(7 / 4)))

Function ArcSinDegrees$ (xRadians)
    a1 = _R2D(_Asin(xRadians))
    If a1 > 0 Then
        diff = 90 - a1
        a2 = 90 + diff
    Else
        diff = -90 - a1
        a2 = -90 + diff + 360
        a1 = a1 + 360
    End If
    ArcSinDegrees$ = _Trim$(Str$(a1)) + " or " + _Trim$(Str$(a2))
End Function

Big Grin
b = b + ...
Reply
#16
Thanks for Your advice. This code works.

I# = _R2D(_ASIN(F# * Sin(_D2R(H#))))

Regards - Chris
Reply
#17
Glad you have it worked out.

I got a new ArcSin function out of it now I need to figure out what to do with a Function with 2 answers to it Big Grin
Probably not acceptable to math definition of function but this one tells the whole truth of what the angle might be.
b = b + ...
Reply
#18
(10-03-2024, 02:39 PM)bplus Wrote: Glad you have it worked out.

I got a new ArcSin function out of it now I need to figure out what to do with a Function with 2 answers to it Big Grin
Probably not acceptable to math definition of function but this one tells the whole truth of what the angle might be.

You'll never know what the angle might be.  Tongue

_ASIN(0.5)  -- this might be 30 degrees.  It might be 150.   It might be 390 degrees.   It might be 510.  Ot could be -330.  Or maybe -210....

So when you hit the _ASIN button, it tells you the first and simplest value that it can be -- 30 degrees.

You can never confer that angle back from the value alone, multiple angles all return that same sine value.
Reply
#19
It's always one of 2 angles as I showed in reply #15, except at pi/2 and -pi/2, saying it is from one angle only is incomplete answer.
b = b + ...
Reply
#20
I like to do things "straight stick," so to speak. Try this stuff out to your heart's content.

Code: (Select All)
_Title "Test sine, cosine, arcsin, arccos functions"
Screen _NewImage(120, 35, 0)
Color 1, 7
Cls
pi = 3.141592653589793
1 Input "Enter x in degrees"; x
xRad = x * pi / 180
SinX = Sin(xRad)
CosX = Cos(xRad)
yrad = _Asin(SinX)
zrad = _Acos(CosX)
y = yrad * 180 / pi
z = zrad * 180 / pi
Print
Print "Angle input x = "; x
Print
Print "Sin(x) = "; SinX
Print "Cos(x) = "; CosX
Print
Print "ArcSin(Sin(x)) in radians = "; yrad, "ArcSin(Sin(x)) in degrees = "; y
Print "ArcCos(Cos(x)) in radians = "; zrad, "ArcCos(Cos(x)) in degrees = "; z
Print
Input "Continue or exit (x to exit) "; cont$
If cont$ = "x" Then End
Print
GoTo 1
End

Thing is, it's really simple to convert radians to degrees or degrees to radians.

Radians * 180/pi = degrees.
Degrees * pi/180 = radians.

Seems easier than remembering the spacial function name, to me.

(Typo corrected. I saw I was printing out the y angle twice at the end, as opposed to y and then z. Sorry. This works right.)

Just so you can see why these formulas hold, simple derivation.

Question: How many radians is 30 degrees?

Answer consists of simple algebra:

2pi / 360 = xradians / 30

Solve for xrad

xrad = 30 * pi/180

xrad = 0.5236 radians

Or the other way around. How many degrees is pi radians?

Answer:

2pi / 360 = pi radians / x

Solve for x (cross multiply)

2pi * x = 360 * pi radians

x degrees = pi radians * 180/pi

x = 180 degrees
Reply




Users browsing this thread: 2 Guest(s)