forked from processing-js/processing-js.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPVector_add_.html
More file actions
125 lines (112 loc) · 2.79 KB
/
Copy pathPVector_add_.html
File metadata and controls
125 lines (112 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
---
layout: default
---
<table cellpadding="0" cellspacing="0" border="0" class="ref-item">
<tr>
<th scope="row">Class</th>
<td>PVector</td>
</tr>
<tr class="name-row">
<th scope="row">Name</th>
<td><h3>add()</h3></td>
</tr>
<tr class="">
<th scope="row">Examples</th>
<td><div class="example"><pre class="">PVector v1, v2;
void setup() {
smooth();
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);
}</pre>
<hr />
<pre>PVector v;
void setup() {
smooth();
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);
}
</pre>
<hr />
<pre>PVector v1, v2;
void setup() {
smooth();
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);
}</pre></div></td>
</tr>
<tr class="">
<th scope="row">Description</th>
<td><p>Adds x, y, and z components to a vector, adds one vector to another, or adds two independent vectors together.
The version of the method that adds two vectors together is a static method and returns a PVector, the others have no return value --
they act directly on the vector. See the examples for more context.</p></td>
</tr>
<tr class="">
<th scope="row">Syntax</th>
<td><pre><kbd>vec</kbd>.add(<kbd>x</kbd>,<kbd>y</kbd>,<kbd>z</kbd>)</pre><br />
<pre><kbd>vec</kbd>.add(<kbd>v</kbd>)</pre><br />
<pre><kbd>PVector</kbd>.add(<kbd>v1</kbd>,<kbd>v2</kbd>)</pre><br /></td>
</tr>
<tr class="">
<th scope="row">Parameters</th>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr class="">
<th scope="row">vec</th>
<td>any variable of type PVector</td>
</tr>
<tr class="">
<th scope="row">x</th>
<td>float: the x component of the vector</td>
</tr>
<tr class="">
<th scope="row">y</th>
<td>float: the y component of the vector</td>
</tr>
<tr class="">
<th scope="row">z</th>
<td>float: the z component of the vector</td>
</tr>
<tr class="">
<th scope="row">v</th>
<td>PVector: the x, y, and z components from a PVector object</td>
</tr>
<tr class="">
<th scope="row">v1</th>
<td>PVector: the x, y, and z components from a PVector object</td>
</tr>
<tr class="">
<th scope="row">v2</th>
<td>PVector: the x, y, and z components from a PVector object</td>
</tr>
</table>
</td>
</tr>
<tr class="">
<th scope="row">Returns</th>
<td>None or PVector</td>
</tr>
<tr class="">
<th scope="row">Usage</th>
<td>Web & Application</td>
</tr>
</table>