-
-
Notifications
You must be signed in to change notification settings - Fork 49.1k
Description
Feature description
in your bezier_curve.py in graphs you can add a feature like
Currently, your BezierCurve class can evaluate the curve at any t, but it cannot compute the tangent direction or derivative of the curve — which is often useful for motion planning, animation, or drawing tools.
def derivative(self, t: float) -> tuple[float, float]:
This will compute the first derivative (tangent vector) of the Bézier curve at a given parameter t.
The derivative of an n-degree Bézier curve is another Bézier curve of degree n - 1:
def derivative(self, t: float) -> tuple[float, float]:
This method computes the tangent vector (or slope) of your Bézier curve at a specific parameter value t, where t ranges from 0 to 1.
When t = 0, you get the tangent direction at the start of the curve.
When t = 1, you get the tangent direction at the end of the curve.
Intermediate values (like t = 0.25, t = 0.5, etc.) give the tangent at those points.
This is extremely useful when:
You want to know the direction of motion along the curve.
You want to compute velocity or acceleration in animations.
You want to draw tangent lines on the curve.