Java Geometry Algorithm manhattanDistance(Point a, Point b)

Here you can find the source of manhattanDistance(Point a, Point b)

Description

Calculate manhattan distance between two locations.

License

Open Source License

Declaration

public static int manhattanDistance(Point a, Point b) 

Method Source Code


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

import java.awt.Point;

public class Main {
    /**/*from  w ww.  j  ava  2 s . co  m*/
     * Calculate manhattan distance between two locations. 
     */
    public static int manhattanDistance(Point a, Point b) {
        return Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
    }
}

Related

  1. lonLatToString(Point2D.Double pt)
  2. makeCircle(double xCenter, double yCenter, double r, int nPoints)
  3. makeCornerTo(GeneralPath gp, Point2D cornerPoint, Point2D nextCornerPoint, float radius)
  4. makeLine(Point2D.Double center, Point2D.Double north, Point2D.Double east)
  5. makeNeighbor(Point theHex, int direction)
  6. mirrorMoveVertically(Point move, int size)
  7. nearestColinearPoint(final double x1, final double y1, final double x2, final double y2, double x, double y)
  8. nearestColinearPoint(final Line2D segment, final Point2D point)
  9. nearestPointOnLine(Line2D l, Point2D p, boolean clampToSegment, Point2D dest)