GitBrincie212 / Apel-Mod

Apel is a library that brings particle animations to the table with flexible behaviour and a clean developer interface. It promises also lots of predefined shapes & paths to help the developer on their particle scene
Other
2 stars 1 forks source link

Correctly compute and index arccos across its entire domain #21

Closed DarthSharkie closed 2 months ago

DarthSharkie commented 2 months ago

The trig table for arccosine values is computing the indices for arccosine incorrectly. This results in ArrayIndexOutOfBoundsException while rendering objects like spheres that need the full domain of arccosine. Arccosine has a domain in the interval [-1, 1] and a range in the interval [0, PI], but it was accepting values from [0, TAU] like sin and cos. This results in half of spheres and ellipsoids not rendering because an exception is thrown on the draw thread.

Therefore, compute a different interval for stepping through the arccosine function and a different normalization function when looking up an arccosine value.

Encapsulation is improved by generating the trig tables upon creation rather than requiring a second interaction with the class to initialize fully.

Also, add documentation for public methods.

This also moves TrigTable into .lib.util.math since it's math.