ecurtiss / CatRom

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

Add method to map `[0, arc length] -> [0, 1]` #29

Open ecurtiss opened 3 months ago

ecurtiss commented 3 months ago

Today, every spline method accepts either a time in [0, 1] or, if the spline is unit-speed, a fractional arc length in [0, 1]. That both options use [0, 1] is confusing. For unit-speed methods, we should provide a simple mapping from [0, arc length] -> [0, 1] so users can use (non-fractional) arc length as input.

function CatRom:RescaleArcLength(arcLength: number): number
    assert(arcLength >= 0 and arcLength <= self.length)
    return arcLength / self.length
end