( begin auto-generated from PVector_rotate.xml ) Rotate the vector by an angle (only 2D vectors), magnitude remains the same ( end auto-generated ) @webref pvector:method @usage web_application @brief Rotate the vector by an angle (2D only) @param theta the angle of rotation
(float theta)
| 917 | * @param theta the angle of rotation |
| 918 | */ |
| 919 | public PVector rotate(float theta) { |
| 920 | float temp = x; |
| 921 | // Might need to check for rounding errors like with angleBetween function? |
| 922 | x = x*PApplet.cos(theta) - y*PApplet.sin(theta); |
| 923 | y = temp*PApplet.sin(theta) + y*PApplet.cos(theta); |
| 924 | return this; |
| 925 | } |
| 926 | |
| 927 | |
| 928 | /** |