2 * Sixth 3D engine. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public License
6 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.sixth.e3d.geometry;
12 public class Point2D implements Cloneable {
19 public Point2D(final double x, final double y) {
24 public Point2D(final Point2D source) {
29 public Point2D add(final Point2D direction) {
36 public Point2D clone() {
37 return new Point2D(this);
40 public void clone(final Point2D source) {
45 public Point2D computeMiddlePoint(final Point2D p1, final Point2D p2) {
46 x = (p1.x + p2.x) / 2d;
47 y = (p1.y + p2.y) / 2d;
51 public double getAngleXY(final Point2D anotherPoint) {
52 return Math.atan2(x - anotherPoint.x, y - anotherPoint.y);
55 public double getDistanceTo(final Point2D anotherPoint) {
56 final double xDiff = x - anotherPoint.x;
57 final double yDiff = y - anotherPoint.y;
59 return Math.sqrt(((xDiff * xDiff) + (yDiff * yDiff)));
62 public Point2D invert() {
68 public void roundToInteger() {
73 public Point2D subtract(final Point2D direction) {
79 public Point3D to3D() {
80 return new Point3D(x, y, 0);
83 public Point2D zero() {