Skip to content

Commit

Permalink
Merge pull request #1 from bstummer/pr
Browse files Browse the repository at this point in the history
Add GetCurvature
  • Loading branch information
bstummer authored Nov 24, 2022
2 parents 4d5ea69 + d09038c commit 3e85c41
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Bezier.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Documentation: https://bstummer.github.io/bezier/
Version of this module: 1.0.0
Version of this module: 1.1.0
Created by Vaschex
Expand Down Expand Up @@ -381,6 +381,16 @@ function BezierCurve:CreateDerivativeCurve(k:number?)
return Bezier.new(new)
end

--[=[
Returns the curvature of the curve at the time t.
@param t -- A number between 0 and 1
]=]
function BezierCurve:GetCurvature(t:number):number
local d = self:GetDerivative(t)
return d:Cross(self:GetSecondDerivative(t)).Magnitude / (d.Magnitude ^ 3)
end

--[=[
Iterates from t = 0 to 1 in the given amount of steps and passes the t value
in a function in each step.
Expand Down

0 comments on commit 3e85c41

Please sign in to comment.