Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Formula
#1
Hello
How to write this line so that the result is in degrees.
I# = ASIN(F# * SIN(H#))

Chris
Reply
#2
I# = _R2D(ASIN(F# * SIN(H#)))

_R2D() is built in function to convert radians to degrees

vise versa is _D2R()
b = b + ...
Reply
#3
I# = _R2D(ASIN(F# * SIN(H#)))
Gives error. From what version of QB64 _R2D is valid.
Reply
#4
(10-02-2024, 08:16 PM)Chris Wrote: I# = _R2D(ASIN(F# * SIN(H#)))
Gives error. From what version of QB64 _R2D is valid.

QB64pe of course, QB64 should work with this as well.

You probably need _Asin() not Asin() or to get QB64pe Big Grin
b = b + ...
Reply
#5
(10-02-2024, 08:16 PM)Chris Wrote: I# = _R2D(ASIN(F# * SIN(H#)))
Gives error. From what version of QB64 _R2D is valid.

If only there was some source of reference information which one might could use to look up information like that...  Perhaps, something... like a wiki??

Big Grin

https://qb64phoenix.com/qb64wiki/index.php/R2D

Quote:Availability
  • QB64 v1.0 and up
  • QB64-PE all versions


I'd say the issue is the lack of underline with the _ASIN command.  

Honestly, I do recommend the wiki for looking up syntax and examples for stuff like this.   There's a reason why we go through so much effort to document these things for the user base, you know.  Wink
Reply
#6
It doesn't work in QB64pe either. Maybe someone who uses trigonometry will chime in
Reply
#7
It works fine!
Code: (Select All)
For a = 0 To _Pi(2) Step _Pi(2 / 18) ' stepping 20 degrees
    Print Int(_R2D(a) + .001); ' convert to rounded up integer
Next


Attached Files Image(s)
   
b = b + ...
Reply
#8
You know what! I wonder about the _ASin() function, it looks funky!!!
Code: (Select All)
For a = 0 To _Pi(2) Step _Pi(2 / 18) ' stepping 20 degrees
    Print Int(_R2D(a) + .001);
    sina = Sin(a)
    Print Int(_R2D(_Asin(sina)) + .001)
Next

   
b = b + ...
Reply
#9
Are you expecting F# and H# to be in degrees as well?

Code: (Select All)
I# = _R2D(_Asin(_D2R(F#) * Sin(_D2R(H#))))

Out of the above, which is radian?  Which is degree?

What is the value for F#?  Is it 0 to 2 * _Pi?  Or is it 0 to 360?
Same for H#.

And what do you expect back for I#?

Plug and play those commands into your formula until you get the degrees where you want them and the radians where you need them.
Reply
#10
(10-02-2024, 09:28 PM)bplus Wrote: You know what! I wonder about the _ASin() function, it looks funky!!!
Code: (Select All)
For a = 0 To _Pi(2) Step _Pi(2 / 18) ' stepping 20 degrees
    Print Int(_R2D(a) + .001);
    sina = Sin(a)
    Print Int(_R2D(_Asin(sina)) + .001)
Next

What's funky about it?   The curve goes up, then down, then up...

[Image: sinegraph2.png]
Reply




Users browsing this thread: 12 Guest(s)