Skip to content

Commit c6582a3

Browse files
authored
Merge pull request jdf#153 from villares/PVector_work
Update PVector.xml description and add method references
2 parents e1e6c67 + 54f7fbf commit c6582a3

1 file changed

Lines changed: 140 additions & 9 deletions

File tree

‎Reference/api_en/PVector.xml‎

Lines changed: 140 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ v2 = PVector(25, 50)
1616
1717
ellipse(v1.x, v1.y, 12, 12)
1818
ellipse(v2.x, v2.y, 12, 12)
19-
v2.add(v1)
19+
v2.add(v1) # v2 += v1
2020
ellipse(v2.x, v2.y, 24, 24)
2121
]]></code>
2222
</example>
2323

24-
2524
<description><![CDATA[
2625
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 <b>mag()</b> and <b>heading()</b>.<br />
2726
<br />
28-
In many of the Processing examples, you will see <b>PVector</b> 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 <b>PVector</b> class.
27+
In many of the Processing examples, you will see <b>PVector</b> 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).<br />
28+
<br />Since vectors represent groupings of values, we'll need to do some "vector" math, which is made easy by the methods inside the <b>PVector</b> class, or, in Python Mode, in some cases the traditional mathematical operators have been "overloaded" to work with PVectors: "+" adds vectors, "-" subtracts vectors, "*" does scalar multiplication, and "/" does scalar division. The related augmented assigment operators, "+=", "-=", "*=", and "/=", also work.
2929
]]></description>
3030

3131
<syntax>
32-
var = PVector(x, y)
33-
var = PVector(x, y, z)
32+
v = PVector(x, y)
33+
v = PVector(x, y, z)
3434
</syntax>
3535

3636
<parameter>
@@ -48,10 +48,141 @@ In many of the Processing examples, you will see <b>PVector</b> used to describe
4848
<description><![CDATA[int: z component of the PVector]]></description>
4949
</parameter>
5050

51-
<parameter>
52-
<label>var</label>
53-
<description><![CDATA[variable which refers to the PVector]]></description>
54-
</parameter>
51+
<method>
52+
<label>set()</label>
53+
<description> Set the components of the vector</description>
54+
<ref>PVector_set</ref>
55+
</method>
56+
57+
<method>
58+
<label>random2D()</label>
59+
<description> Make a new 2D unit vector with a random direction.</description>
60+
<ref>PVector_random2D</ref>
61+
</method>
62+
63+
<method>
64+
<label>random3D()</label>
65+
<description> Make a new 3D unit vector with a random direction.</description>
66+
<ref>PVector_random3D</ref>
67+
</method>
68+
69+
<method>
70+
<label>fromAngle()</label>
71+
<description> Make a new 2D unit vector from an angle</description>
72+
<ref>PVector_fromAngle</ref>
73+
</method>
74+
75+
<method>
76+
<label>fromAngle()</label>
77+
<description> Make a new 2D unit vector from an angle</description>
78+
<ref>PVector_fromAngle</ref>
79+
</method>
80+
81+
<method>
82+
<label>copy()</label>
83+
<description> Get a copy of the vector</description>
84+
<ref>PVector_copy</ref>
85+
</method>
86+
87+
<method>
88+
<label>mag()</label>
89+
<description> Calculate the magnitude of the vector</description>
90+
<ref>PVector_mag</ref>
91+
92+
</method><method>
93+
<label>magSq()</label>
94+
<description> Calculate the magnitude of the vector, squared</description>
95+
<ref>PVector_magSq</ref>
96+
</method>
97+
98+
<method>
99+
<label>add()</label>
100+
<description> Adds x, y, and z components to a vector, one vector to another, or two independent vectors</description>
101+
<ref>PVector_add</ref>
102+
</method>
103+
104+
<method>
105+
<label>sub()</label>
106+
<description> Subtract x, y, and z components from a vector, one vector from another, or two independent vectors</description>
107+
<ref>PVector_sub</ref>
108+
</method>
109+
110+
<method>
111+
<label>mult()</label>
112+
<description> Multiply a vector by a scalar</description>
113+
<ref>PVector_mult</ref>
114+
</method>
115+
116+
<method>
117+
<label>div()</label>
118+
<description> Divide a vector by a scalar</description>
119+
<ref>PVector_div</ref>
120+
</method>
121+
122+
<method>
123+
<label>dist()</label>
124+
<description> Calculate the distance between two points</description>
125+
<ref>PVector_dist</ref>
126+
</method>
127+
128+
<method>
129+
<label>dot()</label>
130+
<description> Calculate the dot product of two vectors</description>
131+
<ref>PVector_dot</ref>
132+
</method>
133+
134+
<method>
135+
<label>cross()</label>
136+
<description> Calculate and return the cross product</description>
137+
<ref>PVector_cross</ref>
138+
</method>
139+
140+
<method>
141+
<label>normalize()</label>
142+
<description> Normalize the vector to a length of 1</description>
143+
<ref>PVector_normalize</ref>
144+
</method>
145+
146+
<method>
147+
<label>limit()</label>
148+
<description> Limit the magnitude of the vector</description>
149+
<ref>PVector_limit</ref>
150+
</method>
151+
152+
<method>
153+
<label>setMag()</label>
154+
<description> Set the magnitude of the vector</description>
155+
<ref>PVector_setMag</ref>
156+
</method>
157+
158+
<method>
159+
<label>heading()</label>
160+
<description> Calculate the angle of rotation for this vector</description>
161+
<ref>PVector_heading</ref>
162+
</method>
163+
164+
<method>
165+
<label>rotate()</label>
166+
<description> Rotate the vector by an angle (2D only)</description>
167+
<ref>PVector_rotate</ref>
168+
</method>
169+
170+
<method>
171+
<label>lerp()</label>
172+
<description> Linear interpolate the vector to another vector</description>
173+
<ref>PVector_lerp</ref>
174+
</method>
175+
176+
<method>
177+
<label>angleBetween()</label>
178+
<description> Calculate and return the angle between two vectors</description>
179+
<ref>PVector_angleBetween</ref>
180+
</method>
55181

182+
<method>
183+
<label>array()</label>
184+
<description> Return a representation of the vector as a float array</description>
185+
<ref>PVector_array</ref>
186+
</method>
56187

57188
</root>

0 commit comments

Comments
 (0)