Java Geometry Algorithm invVec(final Point2D v)

Here you can find the source of invVec(final Point2D v)

Description

Generates a vector pointing in the opposite direction.

License

Open Source License

Parameter

Parameter Description
v The vector.

Return

The inverse vector.

Declaration

public static Point2D invVec(final Point2D v) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.geom.Point2D;

public class Main {
    /**/*from w w w  .  j a  v  a2  s .c om*/
     * Generates a vector pointing in the opposite direction.
     * 
     * @param v The vector.
     * @return The inverse vector.
     */
    public static Point2D invVec(final Point2D v) {
        return mulVec(v, -1.0);
    }

    /**
     * Multiplies a point with a scalar.
     * 
     * @param v Point.
     * @param s Scalar.
     * @return The scaled vector.
     */
    public static Point2D mulVec(final Point2D v, final double s) {
        return new Point2D.Double(v.getX() * s, v.getY() * s);
    }
}

Related

  1. gridAlign(final Point2D point, final double gridX, final double gridY)
  2. hitsLine(final Point2D p, final Point2D fromPoint, final Point2D toPoint, final double thickness)
  3. insidePoly(Polygon pg, Point p)
  4. interceptLineAndBox(Point2D startPosition, Point2D endPosition, RectangularShape boundingBox)
  5. interpol(Point p1, Point p2, float factor)
  6. lonLatToString(Point2D.Double pt)
  7. makeCircle(double xCenter, double yCenter, double r, int nPoints)
  8. makeCornerTo(GeneralPath gp, Point2D cornerPoint, Point2D nextCornerPoint, float radius)
  9. makeLine(Point2D.Double center, Point2D.Double north, Point2D.Double east)