Name

rotate()

Class

PVector

Description

Rotate the vector by an angle (only 2D vectors), magnitude remains the same

Examples

  • PVector v;
    
    void setup() {
      v = new PVector(10.0, 20.0);
      println(v);  // Prints "[ 10.0, 20.0, 0.0 ]"
      v.rotate(HALF_PI);
      println(v);  // Prints "[ -20.0, 9.999999, 0.0 ]"
    }
    

Syntax

  • .rotate(theta)

Parameters

  • theta(float)the angle of rotation

Return

  • PVector