Here you can find the source of findMiddlePoint(Point2D p1, Point2D p2)
Parameter | Description |
---|---|
pointPlace | a parameter |
pointTransition | a parameter |
public static Point2D findMiddlePoint(Point2D p1, Point2D p2)
//package com.java2s; /**//from ww w .j ava2 s . c o m * The MIT License (MIT) Copyright (c) 2016 Pedro Henrique Nascimento Vieira Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ import java.awt.geom.Point2D; public class Main { /** * Return the middle point between p1 and p2. * @param pointPlace * @param pointTransition * @return middle point */ public static Point2D findMiddlePoint(Point2D p1, Point2D p2) { double x = (p1.getX() + p2.getX()) / 2; double y = (p1.getY() + p2.getY()) / 2; return (new Point2D.Double(x, y)); } /** * Return the middle point between p1 and p2. * @param x1 * @param y1 * @param x2 * @param y2 * @return middle point */ public Point2D findMiddlePoint(double x1, double y1, double x2, double y2) { Point2D p1 = new Point2D.Double(x1, y1); Point2D p2 = new Point2D.Double(x2, y2); return (findMiddlePoint(p1, p2)); } }