Merge pull request #1015 from babaissarkar/update_set_heading

Update docs for setHeading
This commit is contained in:
Raphaël de Courville
2025-07-11 12:03:12 +02:00
committed by GitHub
2 changed files with 30 additions and 4 deletions
+17 -4
View File
@@ -848,13 +848,15 @@ public class PVector implements Serializable {
/**
*
* Calculate the angle of rotation for this vector (only 2D vectors)
*
* Calculate the vector's direction, that is, the angle this vector makes
* with the positive X axis (only 2D vectors)
*
*
* @webref pvector:method
* @usage web_application
* @return the angle of rotation
* @return the direction of the vector (angle with positive X axis)
* @webBrief Calculate the angle of rotation for this vector
* @see PVector#setHeading()
*/
public float heading() {
float angle = (float) Math.atan2(y, x);
@@ -867,7 +869,18 @@ public class PVector implements Serializable {
return heading();
}
/**
*
* Sets the angle this vector makes with the positive X axis (only 2D vectors)
* This is equivalent to changing the vector's direction to the given value.
*
* @webref pvector:method
* @usage web_application
* @param angle the direction of the resultant vector
* @return this vector, rotated to have the given direction
* @webBrief Set the direction for this vector
* @see PVector#heading()
*/
public PVector setHeading(float angle) {
float m = mag();
x = (float) (m * Math.cos(angle));
+13
View File
@@ -503,6 +503,7 @@ size FUNCTION2 FloatList_size_
sort FUNCTION2 FloatList_sort_
sortReverse FUNCTION2 FloatList_sortReverse_
sub FUNCTION2 FloatList_sub_
toArray FUNCTION2 FloatList_toArray_
floor FUNCTION1 floor_
focused KEYWORD4 focused
frameCount KEYWORD4 frameCount
@@ -559,6 +560,7 @@ size FUNCTION2 IntList_size_
sort FUNCTION2 IntList_sort_
sortReverse FUNCTION2 IntList_sortReverse_
sub FUNCTION2 IntList_sub_
toArray FUNCTION2 IntList_toArray_
join FUNCTION1 join_
JSONArray KEYWORD5 JSONArray
append FUNCTION2 JSONArray_append_
@@ -579,6 +581,8 @@ setJSONArray FUNCTION2 JSONArray_setJSONArray_
setJSONObject FUNCTION2 JSONArray_setJSONObject_
setString FUNCTION2 JSONArray_setString_
size FUNCTION2 JSONArray_size_
toIntArray FUNCTION2 JSONArray_toIntArray_
toStringArray FUNCTION2 JSONArray_toStringArray_
JSONObject KEYWORD5 JSONObject
getBoolean FUNCTION2 JSONObject_getBoolean_
getFloat FUNCTION2 JSONObject_getFloat_
@@ -751,6 +755,7 @@ random2D FUNCTION2 PVector_random2D_
random3D FUNCTION2 PVector_random3D_
rotate FUNCTION2 PVector_rotate_
set FUNCTION2 PVector_set_
setHeading FUNCTION2 PVector_setHeading_
setMag FUNCTION2 PVector_setMag_
sub FUNCTION2 PVector_sub_
quad FUNCTION1 quad_
@@ -847,6 +852,7 @@ shuffle FUNCTION2 StringList_shuffle_
size FUNCTION2 StringList_size_
sort FUNCTION2 StringList_sort_
sortReverse FUNCTION2 StringList_sortReverse_
toArray FUNCTION2 StringList_toArray_
upper FUNCTION2 StringList_upper_
stroke FUNCTION1 stroke_
strokeCap FUNCTION1 strokeCap_
@@ -911,6 +917,13 @@ unbinary FUNCTION1 unbinary_
unhex FUNCTION1 unhex_
updatePixels FUNCTION1 updatePixels_
vertex FUNCTION1 vertex_
windowMove FUNCTION1 windowMove_
windowMoved FUNCTION1 windowMoved_
windowRatio FUNCTION1 windowRatio_
windowResizable FUNCTION1 windowResizable_
windowResize FUNCTION1 windowResize_
windowResized FUNCTION1 windowResized_
windowTitle FUNCTION1 windowTitle_
XML KEYWORD5 XML
addChild FUNCTION2 XML_addChild_
format FUNCTION2 XML_format_