Processing, 類PVector中的add()用法介紹。
用法
.add(v).add(x, y).add(x, y, z).add(v1, v2).add(v1, v2, target)
參數
v(PVector)要添加的向量x(float)向量的 x 分量y(float)向量的 y 分量z(float)向量的 z 分量v1(PVector)一個向量v2(PVector)另一個向量target(PVector)目標向量(如果為空,將創建一個新向量)
返回
PVector
說明
將 x、y 和 z 分量添加到向量,將一個向量添加到另一個向量,或將兩個獨立向量相加。將兩個向量相加的方法版本是靜態方法並返回一個新的 PVector ,其他方法直接作用於向量本身。有關更多上下文,請參閱示例。
例子
PVector v1, v2;
void setup() {
noLoop();
v1 = new PVector(40, 20, 0);
v2 = new PVector(25, 50, 0);
}
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);
}
PVector v;
void setup() {
noLoop();
v = new PVector(40, 20, 0);
}
void draw() {
ellipse(v.x, v.y, 12, 12);
ellipse(25, 50, 12, 12);
v.add(25, 50, 0);
ellipse(v.x, v.y, 24, 24);
}
PVector v1, v2;
void setup() {
noLoop();
v1 = new PVector(40, 20, 0);
v2 = new PVector(25, 50, 0);
}
void draw() {
ellipse(v1.x, v1.y, 12, 12);
ellipse(v2.x, v2.y, 12, 12);
PVector v3 = PVector.add(v1, v2);
ellipse(v3.x, v3.y, 24, 24);
}
相關用法
- Processing PVector.angleBetween()用法及代碼示例
- Processing PVector.array()用法及代碼示例
- Processing PVector.set()用法及代碼示例
- Processing PVector.mag()用法及代碼示例
- Processing PVector.normalize()用法及代碼示例
- Processing PVector.limit()用法及代碼示例
- Processing PVector.div()用法及代碼示例
- Processing PVector.cross()用法及代碼示例
- Processing PVector.random2D()用法及代碼示例
- Processing PVector.lerp()用法及代碼示例
- Processing PVector.heading()用法及代碼示例
- Processing PVector.dot()用法及代碼示例
- Processing PVector.magSq()用法及代碼示例
- Processing PVector.dist()用法及代碼示例
- Processing PVector.fromAngle()用法及代碼示例
- Processing PVector.random3D()用法及代碼示例
- Processing PVector.z用法及代碼示例
- Processing PVector.y用法及代碼示例
- Processing PVector.x用法及代碼示例
- Processing PVector.setMag()用法及代碼示例
- Processing PVector.rotate()用法及代碼示例
- Processing PVector.sub()用法及代碼示例
- Processing PVector.copy()用法及代碼示例
- Processing PVector用法及代碼示例
- Processing Pulse用法及代碼示例
注:本文由純淨天空篩選整理自processing.org大神的英文原創作品 PVector.add()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
