Name

mag()

Class

PVector

Description

Calculates the magnitude (length) of the vector and returns the result as a float (this is simply the equation sqrt(x*x + y*y + z*z).)

Examples

  • PVector v;
    
    void setup() {
      size(100, 100);
      v = new PVector(20.0, 30.0, 40.0);
      float m = v.mag();
      println(m);  // Prints "53.851646"
    }
    

Syntax

  • .mag()

Return

  • float