Calculates the dot product of two vectors. - Java java.lang

Java examples for java.lang:Math Vector

Description

Calculates the dot product of two vectors.

Demo Code


//package com.java2s;

import java.awt.geom.Point2D;

public class Main {
    /**//from w w  w  .  ja  va  2 s .  co  m
     * Calculates the dot product of two vectors.
     * 
     * @param a The first vector.
     * @param b The second vector.
     * @return The dot product.
     */
    public static double dot(final Point2D a, final Point2D b) {
        return a.getX() * b.getX() + a.getY() * b.getY();
    }
}

Related Tutorials