Open ecurtiss opened 4 months ago
I would bet that >90% of users have never changed alpha or tension. Of the 10% who have, I would bet that >90% have kept within the suggested bounds of [0, 1]. Therefore, I don't think it's a big deal to eliminate values of tension outside of [0, 1]. And when tension is exactly 1, the spline is just a chain of straight lines, so there is no point in using CatRom. Therefore, I think it's not unreasonable to take option 2 and just restrict tension to [0, 1). If users really want straight lines, they can set tension to 0.999.
In addition to the above heuristic argument, I'll add that
An immersed curve is a curve whose speed is always positive. CatRom assumes that its splines are immersed anywhere that
Segment:SolveVelocity
andSegment:SolveTangent
are used internally (and really, in my head, I assume this to always be true). However, a spline with tension 1 has a speed of zero at times t = 0 and t = 1. Moreover, completely straight splines are susceptible to zeros in speed when the spline backtracks on itself, which happens with tensions outside of [0, 1].This leaves us with three solutions:
For option 1, a graceful way to handle non-immersion with
Segment:SolveTangent
is to introduce an internal "safe" version that computes a discrete approximation of the tangent. There's not a great way to makeSegment:SolveVelocity
safe, but given how it's used, I don't think it should be. However, "fixing" these problems feels wrong since the parametrization should always be immersed to begin with. The only exception would be unit-speed parametrizations, which are by definition immersed. But if we choose to gracefully handle unit-speed curves, then I suppose we should also gracefully handle non-unit-speed cases as well.Bookkeeping
Note that we use
Segment:SolveVelocity
inSegment:SolveTangent
Segment:SolveNormal
Segment:SolveCurvature
Segment:SolveTorsion
Segment:SolveCFrameLookAlong
getLengthIntegrand
Segment:_ReparametrizeNewtonBisection
and we use
Segment:SolveTangent
inSegment:SolveNormal
(on Vector2 splines)Segment:SolveBinormal
Segment:SolveCFrameFrenet
Segment:SolveCFrameRMF
Segment:PrecomputeRMFs
Catrom:PrecomputeRMFs