projects
/
sixth-3d.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Removed ViewListener interface. Renamed View to ViewPanel.
[sixth-3d.git]
/
src
/
main
/
java
/
eu
/
svjatoslav
/
sixth
/
e3d
/
geometry
/
Point2D.java
diff --git
a/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Point2D.java
b/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Point2D.java
index
c767ffd
..
1cfd39c
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/sixth/e3d/geometry/Point2D.java
+++ b/
src/main/java/eu/svjatoslav/sixth/e3d/geometry/Point2D.java
@@
-1,14
+1,16
@@
/*
/*
- * Sixth - System for data storage, computation, exploration and interaction.
- * Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
+ * Sixth 3D engine. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 3 of the GNU Lesser General Public License
* or later as published by the Free Software Foundation.
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 3 of the GNU Lesser General Public License
* or later as published by the Free Software Foundation.
+ *
*/
package eu.svjatoslav.sixth.e3d.geometry;
*/
package eu.svjatoslav.sixth.e3d.geometry;
+import static java.lang.Math.sqrt;
+
public class Point2D implements Cloneable {
public double x, y;
public class Point2D implements Cloneable {
public double x, y;
@@
-32,6
+34,10
@@
public class Point2D implements Cloneable {
return this;
}
return this;
}
+ public boolean isZero(){
+ return (x == 0) && (y == 0);
+ }
+
@Override
public Point2D clone() {
return new Point2D(this);
@Override
public Point2D clone() {
return new Point2D(this);
@@
-42,7
+48,7
@@
public class Point2D implements Cloneable {
y = source.y;
}
y = source.y;
}
- public Point2D
computeMiddlePoint
(final Point2D p1, final Point2D p2) {
+ public Point2D
getMiddle
(final Point2D p1, final Point2D p2) {
x = (p1.x + p2.x) / 2d;
y = (p1.y + p2.y) / 2d;
return this;
x = (p1.x + p2.x) / 2d;
y = (p1.y + p2.y) / 2d;
return this;
@@
-52,11
+58,18
@@
public class Point2D implements Cloneable {
return Math.atan2(x - anotherPoint.x, y - anotherPoint.y);
}
return Math.atan2(x - anotherPoint.x, y - anotherPoint.y);
}
+ /**
+ * Compute distance to another point.
+ */
public double getDistanceTo(final Point2D anotherPoint) {
final double xDiff = x - anotherPoint.x;
final double yDiff = y - anotherPoint.y;
public double getDistanceTo(final Point2D anotherPoint) {
final double xDiff = x - anotherPoint.x;
final double yDiff = y - anotherPoint.y;
- return Math.sqrt(((xDiff * xDiff) + (yDiff * yDiff)));
+ return sqrt(((xDiff * xDiff) + (yDiff * yDiff)));
+ }
+
+ public double getVectorLength() {
+ return sqrt(((x * x) + (y * y)));
}
public Point2D invert() {
}
public Point2D invert() {
@@
-70,9
+83,9
@@
public class Point2D implements Cloneable {
y = (int) y;
}
y = (int) y;
}
- public Point2D subtract(final Point2D
direction
) {
- x -=
direction
.x;
- y -=
direction
.y;
+ public Point2D subtract(final Point2D
point
) {
+ x -=
point
.x;
+ y -=
point
.y;
return this;
}
return this;
}