名称:PVector
例子:
PVector v1, v2;
void setup() {
noLoop();
v1 = new PVector(40, 20);
v2 = new PVector(25, 50);
}
void draw() {
ellipse(v1.x, v1.y, 12, 12);
ellipse(v2.x, v2.y, 12, 12);
v2.add(v1);
ellipse(v2.x, v2.y, 24, 24);
}
描述:
A class to describe a two or three dimensional vector, specifically a Euclidean (also known as geometric) vector. A vector is an entity that has both magnitude and direction. The datatype, however, stores the components of the vector (x,y for 2D, and x,y,z for 3D). The magnitude and direction can be accessed via the methods mag() and heading().
一个用于描述二维或三维向量,特别是欧几里德(也称为几何)向量的类。向量是具有大小和方向的实体。其数据类型存储向量的分量(x,y为2D,x,y,z为3D)。我们可以通过mag()和heading()方法访问大小和方向。 In many of the Processing examples, you will see PVector used to describe a position, velocity, or acceleration. For example, if you consider a rectangle moving across the screen, at any given instant it has a position (a vector that points from the origin to its location), a velocity (the rate at which the object’s position changes per time unit, expressed as a vector), and acceleration (the rate at which the object’s velocity changes per time unit, expressed as a vector). Since vectors represent groupings of values, we cannot simply use traditional addition/multiplication/etc. Instead, we’ll need to do some “vector” math, which is made easy by the methods inside the PVector class. 在许多Processing示例中,您可以看到PVector用于描述位置,速度或加速度。例如,如果您考虑在屏幕上移动一个矩形,则在任何给定的时刻,它都有一个位置(一个从原点到其位置的向量),一个速度(每个时间单位的对象位置变化的速率)作为向量)和加速度(物体的速度随时间变化的速率,表示为向量)。由于向量表示值的分组,我们不能简单地使用传统的加法/乘法等。相反,我们需要做一些“向量”数学,而PVector类中的方法使其变得容易。 |
领域 :
|
方法:
|
构造函数:
PVector() PVector(x, y, z) PVector(x, y)
参数:
|
- 本文固定链接: http://iprocessing.cn/2017/07/19/pvector-向量/
- 转载请注明: Hewes 于 Processing编程艺术 发表