Subtracts one point from another point. - Java java.lang

Java examples for java.lang:Math Geometry

Description

Subtracts one point from another point.

Demo Code


//package com.java2s;

import java.awt.geom.Point2D;

public class Main {
    /**// w w w  .  jav  a2s  .  c  o  m
     * Subtracts {@code b} from {@code a}.
     * 
     * @param a The minuend.
     * @param b The subtrahend.
     * @return The difference.
     */
    public static Point2D subVec(final Point2D a, final Point2D b) {
        return new Point2D.Double(a.getX() - b.getX(), a.getY() - b.getY());
    }
}

Related Tutorials