Page 1 of 1

Geometric Combinators

Posted: Mon Jul 15, 2024 3:37 pm
by GreyFoxx
TL;DR
Add trigonometric functions (sin, cos, tan, asin, acos, atan) and hyperbolic functions (sinh, cosh, tanh, asinh, acosh, atanh) to arithmetic combinators, or add a new geometric combinator to support them.

What ?
Arithmetic combinators OR the new geometric combinator can now process trigonometric and hyperbolic calculations for 12 total functions.

The following 6 trigonometric functions are supported:
  • sin: f(θ, M, A) = A * sin(θ * 2π / M)
  • cos: f(θ, M, A) = A * cos(θ * 2π / M)
  • tan: f(θ, M, A) = A * tan(θ * 2π / M)
  • asin: f(y, A, M) = M * asin(y / A) / 2π
  • acos: f(x, A, M) = M * acos(x / A) / 2π
  • atan: f(y, x, M) = M * atan2(y, x) / 2π
Additionally, the following 6 hyperbolic functions are supported:
  • sinh: f(θ, M, A) = A * sinh(θ * 2π / M)
  • cosh: f(θ, M, A) = A * cosh(θ * 2π / M)
  • tanh: f(θ, M, A) = A * tanh(θ * 2π / M)
  • asinh: f(y, A, M) = M * asinh(y / A) / 2π
  • acosh: f(x, A, M) = M * acosh(x / A) / 2π
  • atanh: f(y, x, M) = M * atanh(y, x) / 2π
Each function has 3 inputs and 1 output. The variables used correspond as follows:
  • θ: Angle
  • M: Modulus (Defaults to 360)
  • A: Amplitude (Defaults to 1000)
  • x: Run distance
  • y: Rise distance
All functions take an input modulus. This modulus specifies the degree system used, which might typically be 360 (deg), 400 (grad), or 6283 (rad * 1000). The purpose of the modulus is to provide arbitrary precision to signals, which must be relayed as integers. Most functions also have an input amplitude, which might typically be 1000. The purpose of the amplitude is similar to that of the modulus; to allow arbitrarily precise fractions to be represented as integer signals.

It should be noted that the "atan" function is actually an "atan2" function, taking both rise and run as inputs rather than a slope. This ensures that angles greater than or equal to 90° and less than or equal to -90° are handled correctly. However, it is functionally identical to the other inverse trigonometric functions, as the "y" and "x" inputs may also instead be treated as a slope and an amplitude respectively.

There are 3 ways these functions could be implemented with the existing arithmetic combinator OR in the new geometric combinator:
  1. All 12 functions are added separately.
  2. Only 3 functions are added (sin, cos, tan) where each function also has 2 other options: One for normal/inverse, and the other for trigonometric/hyperbolic (both either as checkboxes, dropdowns, or sliders).
  3. Only 4 functions are added (sin, asin, sinh, asinh) since each of the remaining functions can be easily derived using other combinators.
The hyperbolic functions are a less important part of this feature and could be cut for the sake of simplicity if needed. However, it would only be a matter of time before they are requested following the addition of trigonometric functions.
Why ?
This feature would be massively helpful to anyone interested in using the circuit network for more complex purposes, such as 2D and 3D rendering with lamps, advanced statistical analysis, waveform analysis, and forecasting. It will have niche use, but seeing as the same could be said about combinators in general, having the option there would be nice. (And yes, I have run into a situation where such a feature would've been helpful before.)

Re: Geometric Combinators

Posted: Mon Jul 15, 2024 6:40 pm
by robot256
This is an interesting proposal. I was about to comment that it would be simpler to make your own power series approximation than to look up/remember how the fixed-point trig combinator works, but then remember that while squaring is easy, cubing with combinators is hard/impossible (with the Any signal, I mean).

Re: Geometric Combinators

Posted: Mon Jul 15, 2024 7:23 pm
by GreyFoxx
Oh certainly, there is a way to do it and it isn't particularly difficult, 100%. The problem is you need at least up to the 6th iteration of the series to get a decent approximation. Assuming you want a precision of 3 decimal points, cubing your number nearly pushes it over the integer overflow. To do this in-game with a good amount of padding, you'd likely need a whopping 62 arithmetic combinators. :lol: