{"id":"ecurtiss/catrom","name":"catrom","scope":"ecurtiss","platform":"roblox","description":"Mirrored from the Wally registry.","version":"0.6.0","latest":"0.6.0","versions":["0.6.0","1.0.0-rc1"],"license":"MIT","licenseRating":"safe","licenseCaveats":["License identified from the packaged LICENSE file; the manifest declared none."],"licenseVerified":true,"dependencies":{},"integrity":"d5222acafa78056403d6641ce119271126875a50421b4ab22108002961ee576c","likes":0,"downloads":0,"install":"forest install ecurtiss/catrom","url":"https://forest.dev/p/roblox/ecurtiss/catrom","files":"https://api.forest.dev/ai/package/roblox/ecurtiss/catrom/files","readme":"<div align=\"center\">\r\n\t<img src=\"https://github.com/ecurtiss/CatRom/blob/master/docs/logo-light.svg#gh-light-mode-only\" height=\"180\" alt=\"CatRom logo\"/>\r\n\t<img src=\"https://github.com/ecurtiss/CatRom/blob/master/docs/logo-dark.svg#gh-dark-mode-only\" height=\"180\" alt=\"CatRom logo\"/>\r\n\t<hr/>\r\n</div>\r\n\r\nCreates [Catmull-Rom splines](https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline).\r\n\r\nThe Catmull-Rom spline (CatRom) is a cousin of the popular Bézier curve that passes through all of its control points.\r\n\r\n<img src=\"docs/tube.png\" height=\"300\"/>\r\n\r\n## How to use\r\nThe CatRom constructor takes 3 arguments:\r\n1. `points`: An array of Vector2s, Vector3s, or CFrames.\r\n2. `alpha` [optional]: A number (usually) in [0, 1] that determines the \"parametrization\" of the spline; defaults to 0.5.\r\n3. `tension` [optional]: A number (usually) in [0, 1] that determines how loose the spline is; defaults to 0.\r\n\r\nThe default `alpha` of 0.5 is the only way to avoid cusps and loops, as shown [in this paper](http://www.cemyuksel.com/research/catmullrom_param/).\r\n\r\n## API\r\n___\r\nThe `unitSpeed` argument in each `Solve` method determines whether the calculation uses a unit-speed parametrization of the spline. A unit-speed parametrization (also called an arc length parametrization) has a constant speed of 1, which yields equally spaced points given equally spaced times. This is often visually desirable but increases computation time.\r\n___\r\n```lua\r\nCatRom.new(points: array, alpha: number?, tension: number?)\r\n```\r\nCreates a new Catmull-Rom spline from a list of Vector2s, Vector3s, or CFrames.\r\n```lua\r\nCatRom:SolvePosition(t: number, unitSpeed: boolean?)\r\n```\r\nReturns the position of the spline at time `t`.\r\n```lua\r\nCatRom:SolveCFrame(t: number, unitSpeed: boolean?)\r\n```\r\nReturns a CFrame at position `SolvePosition(t)` that faces in the direction of `SolveTangent(t)`.\r\n```lua\r\nCatRom:SolveRotCFrame(t: number, unitSpeed: boolean?)\r\n```\r\nReturns a CFrame at position `SolvePosition(t)` with orientation interpolated between the previous and next control points (provided your control points are CFrames). The interpolation uses spherical quadrangle interpolation.\r\n```lua\r\nCatRom:SolveVelocity(t: number, unitSpeed: boolean?)\r\n```\r\nReturns the velocity of the spline at time `t`.\r\n```lua\r\nCatRom:SolveAcceleration(t: number, unitSpeed: boolean?)\r\n```\r\nReturns the acceleration of the spline at time `t`.\r\n```lua\r\nCatRom:SolveTangent(t: number, unitSpeed: boolean?)\r\n```\r\nReturns the forward-facing, unit-length tangent vector at time `t`.\r\n```lua\r\nCatRom:SolveNormal(t: number, unitSpeed: boolean?)\r\n```\r\nReturns a unit-length vector at time `t` that is perpendicular to the spline and points in the direction of curvature. Returns `Vector3.new(nan, nan, nan)` when the curvature is 0.\r\n```lua\r\nCatRom:SolveBinormal(t: number, unitSpeed: boolean?)\r\n```\r\nReturns the cross product of `SolveTangent(t)` and `SolveNormal(t)`.\r\n```lua\r\nCatRom:SolveCurvature(t: number, unitSpeed: boolean?)\r\n```\r\nReturns the curvature of the spline at time `t`.\r\n```lua\r\nCatRom:SolveLength(a: number?, b: number?)\r\n```\r\nReturns the arc length between the points at times `a` and `b`.\r\n```lua\r\nCatRom:PrecomputeArcLengthParams(numIntervals: number?)\r\n```\r\nComputes a lookup table that makes `unitSpeed` calculations faster but less accurate.\r\n\r\n## Performance Tips\r\n### 1. Solving with `unitSpeed`\r\nIf you are calling many Solve methods with `unitSpeed` true, you should call `PrecomputeArcLengthParams()` immediately after construction. This will make your `unitSpeed` calls less accurate but cheaper to compute. The accuracy can be further tuned using the `numIntervals` argument; lower is faster and less accurate, higher is slower and more accurate (defaults to 16).\r\n\r\n### 2. Repeated inputs\r\nIf you are calling many methods on the *same* input like so\r\n```lua\r\nlocal t -- number in [0, 1]\r\nlocal catRom -- a CatRom object\r\ncatRom:SolvePosition(t)\r\ncatRom:SolveVelocity(t)\r\ncatRom:SolveTangent(t)\r\n```\r\nthen it is faster to instead do\r\n```lua\r\nlocal t -- number in [0, 1]\r\nlocal catRom -- a CatRom object\r\nlocal spline, splineTime = catRom:GetSplineAtTime(t)\r\nspline:SolvePosition(splineTime)\r\nspline:SolveVelocity(splineTime)\r\nspline:SolveTangent(splineTime)\r\n```","readmeTruncated":false}