curve_tangent()#

Calculates the tangent of a point on a curve.

Examples#

example picture for curve_tangent()
 1def setup():
 2    py5.no_fill()
 3    py5.curve(5, 26, 73, 24, 73, 61, 15, 65)
 4    steps = 6
 5    for i in range(0, steps+1):
 6        t = i / steps
 7        x = py5.curve_point(5, 73, 73, 15, t)
 8        y = py5.curve_point(26, 24, 61, 65, t)
 9        #ellipse(x, y, 5, 5)
10        tx = py5.curve_tangent(5, 73, 73, 15, t)
11        ty = py5.curve_tangent(26, 24, 61, 65, t)
12        a = py5.atan2(ty, tx)
13        a -= py5.PI/2.0
14        py5.line(x, y, py5.cos(a)*8 + x, py5.sin(a)*8 + y)

Description#

Calculates the tangent of a point on a curve. There’s a good definition of tangent on Wikipedia.

Underlying Processing method: curveTangent

Syntax#

curve_tangent(a: float, b: float, c: float, d: float, t: float, /) -> float

Parameters#

  • a: float - coordinate of first point on the curve

  • b: float - coordinate of first control point

  • c: float - coordinate of second control point

  • d: float - coordinate of second point on the curve

  • t: float - value between 0 and 1

Updated on November 12, 2021 11:30:58am UTC