ecurtiss / CatRom

Creates Catmull-Rom splines for Roblox
https://ecurtiss.github.io/CatRom/
Mozilla Public License 2.0
45 stars 11 forks source link

Improve speed of :SolveVelocity() and :SolveAcceleration() #5

Closed ecurtiss closed 1 year ago

ecurtiss commented 1 year ago

In the following code, the 2 * self.b, 3 * self.a, and 6 * self.a can be cached. This is particularly important for :SolveVelocity(), which is used heavily for arc length reparametrization. https://github.com/EthanCurtiss/CatRom/blob/5a1c066d23dc660f4733e6ac10d1022cf24c7852/src/Spline.lua#L105-L113

ecurtiss commented 1 year ago

This (red bar) turns out to not be faster than the original (green bar). The other two benchmarks are unrelated to this issue. image