Reference+
Name
curveTangent()
Description
Calculates the tangent of a point on a curve. There's a good definition of tangent on Wikipedia.
Examples
size(400, 400); noFill(); curve(20, 104, 292, 96, 292, 244, 60, 260); int steps = 6; for (int i = 0; i <= steps; i++) { float t = i / float(steps); float x = curvePoint(20, 292, 292, 60, t); float y = curvePoint(104, 96, 244, 260, t); //ellipse(x, y, 20, 20); float tx = curveTangent(20, 292, 292, 60, t); float ty = curveTangent(104, 96, 244, 260, t); float a = atan2(ty, tx); a -= PI/2.0; line(x, y, cos(a)*32 + x, sin(a)*32 + y); }
Syntax
curveTangent(a, b, c, d, t)
Parameters
a
(float)
coordinate of first point on the curveb
(float)
coordinate of first control pointc
(float)
coordinate of second control pointd
(float)
coordinate of second point on the curvet
(float)
value between 0 and 1
Return
float
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.