首页 > 文档 > bezierTangent()贝塞尔曲线切线
2017
07-29

bezierTangent()贝塞尔曲线切线

Name

bezierTangent()贝塞尔曲线切线

   

Examples

bezierTangent()贝塞尔曲线切线 - 第1张  | Processing编程艺术

noFill();

bezier(85, 20, 10, 10, 90, 90, 15, 80);

int steps = 6;

fill(255);

for (int i = 0; i <= steps; i++) {

float t = i / float(steps);

// Get the location of the point

float x = bezierPoint(85, 10, 90, 15, t);

float y = bezierPoint(20, 10, 90, 80, t);

// Get the tangent points

float tx = bezierTangent(85, 10, 90, 15, t);

float ty = bezierTangent(20, 10, 90, 80, t);

// Calculate an angle from the tangent points

float a = atan2(ty, tx);

a += PI;

stroke(255, 102, 0);

line(x, y, cos(a)*30 + x, sin(a)*30 + y);

// The following line of code makes a line

// inverse of the above line

//line(x, y, cos(a)*-30 + x, sin(a)*-30 + y);

stroke(0);

ellipse(x, y, 5, 5);

}

bezierTangent()贝塞尔曲线切线 - 第2张  | Processing编程艺术

noFill();

bezier(85, 20, 10, 10, 90, 90, 15, 80);

stroke(255, 102, 0);

int steps = 16;

for (int i = 0; i <= steps; i++) {

float t = i / float(steps);

float x = bezierPoint(85, 10, 90, 15, t);

float y = bezierPoint(20, 10, 90, 80, t);

float tx = bezierTangent(85, 10, 90, 15, t);

float ty = bezierTangent(20, 10, 90, 80, t);

float a = atan2(ty, tx);

a -= HALF_PI;

line(x, y, cos(a)*8 + x, sin(a)*8 + y);

}

Description

Calculates the tangent of a point on a Bezier curve. There is a good definition of tangent on Wikipedia.

计算贝塞尔曲线上的点的正切值。在维基百科上有一个很好的切线定义。

Syntax

bezierTangent(a, b, c, d, t)

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

浮点数:值在01之间

Returns

float

Related

bezier()
bezierVertex()
curvePoint()



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。