Java examples for java.lang:Math Geometry Shape
get Mid Point
//package com.java2s; import java.awt.geom.Point2D; public class Main { /**/*from w ww. jav a2 s. c o m*/ * @return midPoint or null if any argument is invalid */ public static Point2D.Double getMidPoint(Point2D ptA, Point2D ptB) { if (ptA != null && ptB != null) { return new Point2D.Double((ptA.getX() + ptB.getX()) / 2.0, (ptA.getY() + ptB.getY()) / 2.0); } return null; } }