Name

magSq()

Class

PVector

Description

Calculates the magnitude (length) of the vector, squared. This method is often used to improve performance since, unlike mag(), it does not require a sqrt() operation.

Examples

  • PVector v;
    
    void setup() {
      v = new PVector(20.0, 30.0, 40.0);
      float m = v.magSq();
      println(m);  // Prints "2900.0"
    }
    

Syntax

  • .magSq()

Return

  • float