QB64 Phoenix Edition
Formula - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2)
+--- Thread: Formula (/showthread.php?tid=3092)

Pages: 1 2


Formula - Chris - 10-02-2024

Hello
How to write this line so that the result is in degrees.
I# = ASIN(F# * SIN(H#))

Chris


RE: Formula - bplus - 10-02-2024

I# = _R2D(ASIN(F# * SIN(H#)))

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

vise versa is _D2R()


RE: Formula - Chris - 10-02-2024

I# = _R2D(ASIN(F# * SIN(H#)))
Gives error. From what version of QB64 _R2D is valid.


RE: Formula - bplus - 10-02-2024

(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


RE: Formula - SMcNeill - 10-02-2024

(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


RE: Formula - Chris - 10-02-2024

It doesn't work in QB64pe either. Maybe someone who uses trigonometry will chime in


RE: Formula - bplus - 10-02-2024

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



RE: Formula - bplus - 10-02-2024

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

   


RE: Formula - SMcNeill - 10-02-2024

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.


RE: Formula - SMcNeill - 10-02-2024

(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]