Name

fromAngle()

Class

PVector

Description

Calculates and returns a new 2D unit vector from the specified angle value (in radians).

Examples

  • PVector v;
    
    void setup() {
      v = PVector.fromAngle(0.01);
      println(v);  // Prints "[ 0.99995, 0.009999833, 0.0 ]"
    }
    

Syntax

  • .fromAngle(angle)
  • .fromAngle(angle, target)

Parameters

  • angle(float)the angle in radians
  • target(PVector)the target vector (if null, a new vector will be created)

Return

  • PVector