Skip to content

Commit

Permalink
Add the denominator to curvature checks
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncozens committed Jun 11, 2024
1 parent ada4db0 commit 4e1c8f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion beziers/cubicbezier.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def curvatureAtTime(self, t: float) -> float:
return (
d.pointAtTime(t).x * d2.pointAtTime(t).y
- d.pointAtTime(t).y * d2.pointAtTime(t).x
)
) / ((d.pointAtTime(t).x ** 2 + d.pointAtTime(t).y ** 2) ** 1.5)

@property
def tunniPoint(self) -> Point:
Expand Down
8 changes: 8 additions & 0 deletions beziers/quadraticbezier.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ def findExtremes(self):
"""Returns a list of time `t` values for extremes of the curve."""
return self._findDRoots()

def curvatureAtTime(self, t: float) -> float:
"""Returns the C curvature at time `t`."""
d = self.derivative()
d2 = self.end - self.start # A constant
return (d.pointAtTime(t).x * d2.y - d.pointAtTime(t).y * d2.x) / (
(d.pointAtTime(t).x ** 2 + d.pointAtTime(t).y ** 2) ** 1.5
)

@property
def area(self):
"""Returns the signed area between the curve and the y-axis"""
Expand Down

0 comments on commit 4e1c8f9

Please sign in to comment.