Compute the squared norm of a vector - Java java.lang

Java examples for java.lang:Math Vector

Description

Compute the squared norm of a vector

Demo Code


import javax.vecmath.Point2d;
import javax.vecmath.Tuple2d;
import javax.vecmath.Vector2d;

public class Main{
    /**//w  ww  . j  a v  a  2  s  .  co  m
     * Compute the squared norm of a vector
     * @param v vector to compute squared norm
     * @return the vector squared norm
     */
    public static double norm2(final Vector2d v) {
        return v.x * v.x + v.y * v.y;
    }
}

Related Tutorials