Skip to content

Commit 5c1278a

Browse files
committed
PVector doc update
1 parent 29a019a commit 5c1278a

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

core/src/processing/core/PVector.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -848,13 +848,15 @@ public PVector setMag(PVector target, float len) {
848848

849849
/**
850850
*
851-
* Calculate the angle of rotation for this vector (only 2D vectors)
852-
*
851+
* Calculate the vector's direction, that is, the angle this vector makes
852+
* with the positive X axis (only 2D vectors)
853+
*
853854
*
854855
* @webref pvector:method
855856
* @usage web_application
856-
* @return the angle of rotation
857+
* @return the direction of the vector (angle with positive X axis)
857858
* @webBrief Calculate the angle of rotation for this vector
859+
* @see PVector#setHeading()
858860
*/
859861
public float heading() {
860862
float angle = (float) Math.atan2(y, x);
@@ -867,7 +869,18 @@ public float heading2D() {
867869
return heading();
868870
}
869871

870-
872+
/**
873+
*
874+
* Sets the angle this vector makes with the positive X axis (only 2D vectors)
875+
* This is equivalent to changing the vector's direction to the given value.
876+
*
877+
* @webref pvector:method
878+
* @usage web_application
879+
* @param angle the direction of the resultant vector
880+
* @return this vector, rotated to have the given direction
881+
* @webBrief Set the direction for this vector
882+
* @see PVector#heading()
883+
*/
871884
public PVector setHeading(float angle) {
872885
float m = mag();
873886
x = (float) (m * Math.cos(angle));

0 commit comments

Comments
 (0)