QB64 Phoenix Edition
Extended Trig Methods - 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: Extended Trig Methods (/showthread.php?tid=2388)

Pages: 1 2


Extended Trig Methods - dbox - 01-15-2024

In the process of trying to expand QBJS' support for QB64 keywords I noticed a curiosity with the extended trigonometric functions.  It looks like this has been the case for some time and predates "the incident".

There is a bit of inconsistency with the documentation in the wiki(s) for the support of these keywords.  Some are well documented and have their own page like: _acos, _asin, _hypot, etc..  Many of them, however, are only referenced in the "Derived Mathematical Functions" section of the Mathematical Operations page.  This section, though, is really just a reference of how to implement your own trig functions and doesn't really indicate that many (but not all) of those methods are actually available in the language.

The following functions from this section have first-class keyword support:
_sec, _csc, _cot, _arcsec, _arccsc, _arccot, _sinh, _cosh, _tanh, _sech, _csch, _coth

...while these do not have a dedicated keyword:
_arcsin, arccos, _arcsinh, _arccosh, _arccsch, _arccoth

So the curiosity that I found is related to the _arccsc method.  If you run the following example you will see that you get two different answers for built-in function vs the provided logic in the wiki:

Code: (Select All)
Print _Arccsc(x)
Print Atn(1 / Sqr(1 - x * x)) + (Sgn(x) - 1) * (2 * Atn(1))

Which one is right?


RE: Extended Trig Methods - SpriggsySpriggs - 01-15-2024

I wish I understood math well enough to actually use these functions.


RE: Extended Trig Methods - SMcNeill - 01-15-2024

(01-15-2024, 02:34 PM)dbox Wrote: In the process of trying to expand QBJS' support for QB64 keywords I noticed a curiosity with the extended trigonometric functions.  It looks like this has been the case for some time and predates "the incident".

There is a bit of inconsistency with the documentation in the wiki(s) for the support of these keywords.  Some are well documented and have their own page like: _acos, _asin, _hypot, etc..  Many of them, however, are only referenced in the "Derived Mathematical Functions" section of the Mathematical Operations page.  This section, though, is really just a reference of how to implement your own trig functions and doesn't really indicate that many (but not all) of those methods are actually available in the language.

The following functions from this section have first-class keyword support:
_sec, _csc, _cot, _arcsec, _arccsc, _arccot, _sinh, _cosh, _tanh, _sech, _csch, _coth

...while these do not have a dedicated keyword:
_arcsin, arccos, _arcsinh, _arccosh, _arccsch, _arccoth

So the curiosity that I found is related to the _arccsc method.  If you run the following example you will see that you get two different answers for built-in function vs the provided logic in the wiki:

Code: (Select All)
Print _Arccsc(x)
Print Atn(1 / Sqr(1 - x * x)) + (Sgn(x) - 1) * (2 * Atn(1))

Which one is right?

https://qb64phoenix.com/qb64wiki/index.php/ACOS
https://qb64phoenix.com/qb64wiki/index.php/ASIN
https://qb64phoenix.com/qb64wiki/index.php/ASINH
https://qb64phoenix.com/qb64wiki/index.php/ACOSH


RE: Extended Trig Methods - SMcNeill - 01-15-2024

And some of those where wrong, as discussed and patched here: https://qb64phoenix.com/forum/showthread.php?tid=2125

I don't know if the wiki was ever corrected, or not.  Someone will need to check that soon.  Wink


RE: Extended Trig Methods - dbox - 01-15-2024

(01-15-2024, 02:49 PM)SMcNeill Wrote: And some of those where wrong, as discussed and patched here: https://qb64phoenix.com/forum/showthread.php?tid=2125

I don't know if the wiki was ever corrected, or not.  Someone will need to check that soon.  Wink
Didn't see that thread.  That is helpful.  Thanks!


RE: Extended Trig Methods - TerryRitchie - 01-15-2024

(01-15-2024, 02:38 PM)SpriggsySpriggs Wrote: I wish I understood math well enough to actually use these functions.
I envy those too that understand math to this degree. When I need to use Trig functions I usually have to take a few hours to study up and relearn how (and most importantly why) to use them. Then after a few weeks the information disappears from my brain and the cycle needs to repeat the next time. Confused

I always considered myself somewhat of a math whiz until I started seriously programming games. Even simple 2D games humbled me quite a bit.


RE: Extended Trig Methods - RhoSigma - 01-15-2024

(01-15-2024, 02:49 PM)SMcNeill Wrote: And some of those where wrong, as discussed and patched here: https://qb64phoenix.com/forum/showthread.php?tid=2125

I don't know if the wiki was ever corrected, or not.  Someone will need to check that soon.  Wink

Indeed, there are a  couple math keywords without a dedicated wiki page yet. Those should have been added by the one who actually implemented the keywords into the language and hence knows best how they work. However, I've no idea who was it, my best guess either of @luke, @FellippeHeitor or @SMcNeill .

_ARCCOT, _ARCCSC, _ARCSEC, _COT, _COTH, _COSH, _CSC, _CSCH, _SEC, _SECH, _SINH, _TANH

In alternative anybody who's familiar with this kind of math could take the task, just let me know if you need a wiki account. Wish my Dad would still be alive, as math teacher he could explain all this to the best, unfortunately I did not inherit much of his math talents  Big Grin


RE: Extended Trig Methods - FellippeHeitor - 01-15-2024

(01-15-2024, 04:56 PM)RhoSigma Wrote:
(01-15-2024, 02:49 PM)SMcNeill Wrote: And some of those where wrong, as discussed and patched here: https://qb64phoenix.com/forum/showthread.php?tid=2125

I don't know if the wiki was ever corrected, or not.  Someone will need to check that soon.  Wink

Indeed, there are a  couple math keywords without a dedicated wiki page yet. Those should have been added by the one who actually implemented the keywords into the language and hence knows best how they work. However, I've no idea who was it, my best guess either of @luke, @FellippeHeitor or @SMcNeill.

_ARCCOT, _ARCCSC, _ARCSEC, _COT, _COTH, _COSH, _CSC, _CSCH, _SEC, _SECH, _SINH, _TANH

In alternative anybody who's familiar with this kind of math could take the task, just let me know if you need a wiki account. Wish my Dad would still be alive, as math teacher he could explan all this to the best, unfortunately I did not inherit much of his math talents  Big Grin


I've no idea either. I barely touch any maths...


RE: Extended Trig Methods - bplus - 01-15-2024

@dbox to be a total nag, it seems to me a more productive use of time to get _Maptriangle working than exotic math functions. Smile

The only people that would use exotic math functions can create their own from building blocks of the basic ones such as Sin, Cos and Tan and their Arc- prefixes because they would be quite familiar with and skilled at using Trig Indentities.


RE: Extended Trig Methods - dbox - 01-15-2024

(01-15-2024, 06:42 PM)bplus Wrote: @dbox to be a total nag, it seems to me a more productive use of time to get _Maptriangle working than exotic math functions. Smile

The only people that would use exotic math functions can create their own from building blocks of the basic ones such as Sin, Cos and Tan and their Arc- prefixes because they would be quite familiar with and skilled at using Trig Indentities.

Fair point @bplus.  With each release, in addition to the larger development efforts, I try to throw in several "low-hanging fruit" keywords to keep expanding the supported list.  That's what these were "supposed" to be until I noticed the results weren't matching.

And I really am trying to focus on the fundamentals first, as much as possible.  With that being said, there is still a good bit of core QBasic/QB64 functionality that still needs to be supported in QBJS.  For example, this release will provide support for Static method variable declaration which hasn't been available to date, along with numerous additional core language support updates.  Another example is support for the "Dim As Integer a, b, c" style variable declaration in custom types that I know has tripped you up on a couple of ported programs.

_MapTriangle is still in the works, however, it is essentially an entire 3d engine disguised as a single method.  It requires adding an additional WebGL canvas to QBJS and support for all the layering options with the current 2d canvas.  I have some somewhat working prototypes, but it is still ways off.

In the meantime, I am getting close on the 0.8.0 release which I should be able to publish soon.  And as a reminder, there are expanded 2d graphics routines available in QBJS that allow you to do a lot of the things _MapTriangle is used for (e.g. RotoZoom, FillTriangle).