You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2019/05/20 13:39:28 UTC
[commons-geometry] 15/16: Trailing spaces, syntax convention.
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
commit 7a42a6f317b0de8ee63b0461e868532c8e025b4e
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Mon May 20 15:24:28 2019 +0200
Trailing spaces, syntax convention.
---
.../commons/geometry/euclidean/threed/Line.java | 6 ++--
.../commons/geometry/euclidean/threed/Plane.java | 33 +++++++++-------------
.../geometry/euclidean/threed/PlaneTest.java | 32 ++++++++++-----------
3 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line.java
index 4835682..9f859e7 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line.java
@@ -248,13 +248,13 @@ public class Line implements Embedding<Vector3D, Vector1D> {
/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
- if (this == obj){
+ if (this == obj) {
return true;
}
- if (obj == null){
+ if (obj == null) {
return false;
}
- if (getClass() != obj.getClass()){
+ if (getClass() != obj.getClass()) {
return false;
}
Line other = (Line) obj;
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Plane.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Plane.java
index 8c1ce6b..f82ae52 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Plane.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Plane.java
@@ -62,8 +62,7 @@ public final class Plane implements Hyperplane<Vector3D>, Embedding<Vector3D, Ve
this.u = u;
this.v = v;
this.w = w;
- if (areCoplanar(u, v, w, precision))
- {
+ if (areCoplanar(u, v, w, precision)) {
throw new IllegalArgumentException("Provided vectors must not be coplanar.");
}
this.originOffset = originOffset;
@@ -80,8 +79,7 @@ public final class Plane implements Hyperplane<Vector3D>, Embedding<Vector3D, Ve
* @throws IllegalNormException if the norm of the given values is zero, NaN, or infinite.
* @throws IllegalArgumentException if the provided vectors are collinear
*/
- public static Plane fromPointAndPlaneVectors (final Vector3D p, final Vector3D u, final Vector3D v, final DoublePrecisionContext precision)
- {
+ public static Plane fromPointAndPlaneVectors (final Vector3D p, final Vector3D u, final Vector3D v, final DoublePrecisionContext precision) {
Vector3D uNorm = u.normalize();
Vector3D vNorm = uNorm.orthogonal(v);
Vector3D wNorm = uNorm.cross(vNorm).normalize();
@@ -97,7 +95,7 @@ public final class Plane implements Hyperplane<Vector3D>, Embedding<Vector3D, Ve
* @return a new plane
* @throws IllegalNormException if the norm of the given values is zero, NaN, or infinite.
*/
- public static Plane fromNormal(final Vector3D normal, final DoublePrecisionContext precision){
+ public static Plane fromNormal(final Vector3D normal, final DoublePrecisionContext precision) {
return fromPointAndNormal(Vector3D.ZERO, normal, precision);
}
@@ -167,8 +165,7 @@ public final class Plane implements Hyperplane<Vector3D>, Embedding<Vector3D, Ve
*
* @return the offset of the origin with respect to the plane.
*/
- public double getOriginOffset()
- {
+ public double getOriginOffset() {
return originOffset;
}
@@ -243,8 +240,7 @@ public final class Plane implements Hyperplane<Vector3D>, Embedding<Vector3D, Ve
* @param line the line to project
* @return the projection of the given line onto the plane.
*/
- public Line project(final Line line)
- {
+ public Line project(final Line line) {
Vector3D direction = line.getDirection();
Vector3D projection = w.multiply(direction.dot(w) * (1/w.normSq()));
Vector3D projectedLineDirection = direction.subtract(projection);
@@ -487,8 +483,7 @@ public final class Plane implements Hyperplane<Vector3D>, Embedding<Vector3D, Ve
* @param line line to check
* @return true if line is contained in this plane
*/
- public boolean contains(final Line line)
- {
+ public boolean contains(final Line line) {
Vector3D origin = line.getOrigin();
Vector3D direction = line.getDirection();
return contains(origin) && areCoplanar(u, v, direction, precision);
@@ -542,9 +537,8 @@ public final class Plane implements Hyperplane<Vector3D>, Embedding<Vector3D, Ve
* @return the distance or 0.0, if the line is not parallel to the plane instance.
*/
public double getOffset(final Line line) {
- if (!isParallel(line))
- {
- return 0.0;
+ if (!isParallel(line)) {
+ return 0;
}
return getOffset(line.getOrigin());
}
@@ -575,7 +569,7 @@ public final class Plane implements Hyperplane<Vector3D>, Embedding<Vector3D, Ve
*/
@Override
public boolean sameOrientationAs(final Hyperplane<Vector3D> other) {
- return (((Plane) other).w).dot(w) > 0.0;
+ return (((Plane) other).w).dot(w) > 0;
}
@Override
@@ -592,13 +586,13 @@ public final class Plane implements Hyperplane<Vector3D>, Embedding<Vector3D, Ve
/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
- if (this == obj){
+ if (this == obj) {
return true;
}
- if (obj == null){
+ if (obj == null) {
return false;
}
- if (getClass() != obj.getClass()){
+ if (getClass() != obj.getClass()) {
return false;
}
Plane other = (Plane) obj;
@@ -614,8 +608,7 @@ public final class Plane implements Hyperplane<Vector3D>, Embedding<Vector3D, Ve
* @param precision precision context used to compare floating point values
* @return true if vectors are coplanar, false otherwise.
*/
- private static boolean areCoplanar(final Vector3D u, final Vector3D v, final Vector3D w, final DoublePrecisionContext precision)
- {
+ private static boolean areCoplanar(final Vector3D u, final Vector3D v, final Vector3D w, final DoublePrecisionContext precision) {
return precision.eqZero(u.dot(v.cross(w)));
}
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
index 957f38f..d250269 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
@@ -40,7 +40,7 @@ public class PlaneTest {
public void testUAndVAreCollinear() {
Plane.fromPointAndPlaneVectors(Vector3D.of(0, 0, 1), Vector3D.of(0, 0, 1), Vector3D.of(0, 0, 2), TEST_PRECISION);
}
-
+
@Test(expected=IllegalNormException.class)
public void testUAndVAreCollinear2() {
Plane.fromPointAndPlaneVectors(Vector3D.of(0, 0, 1), Vector3D.of(0, 0, 1), Vector3D.of(0, 0, -2), TEST_PRECISION);
@@ -50,7 +50,7 @@ public class PlaneTest {
public void testPointsDoNotConstituteAPlane() {
Plane.fromPoints(Vector3D.of(0, 0, 1), Vector3D.of(0, 0, 1), Vector3D.of(0, 1, 0), TEST_PRECISION);
}
-
+
@Test
public void testContains() {
Plane plane = Plane.fromPointAndNormal(Vector3D.of(0, 0, 1), Vector3D.of(0, 0, 1), TEST_PRECISION);
@@ -65,25 +65,25 @@ public class PlaneTest {
Line line = new Line(Vector3D.of(1, 0, 1), Vector3D.of(2, 0, 1), TEST_PRECISION);
Assert.assertTrue(plane.contains(line));
}
-
+
@Test(expected=IllegalNormException.class)
public void testFromPointPlaneVectorsWithZeroVector()
{
Plane.fromPointAndPlaneVectors(Vector3D.of(0, 0, 1), Vector3D.ZERO, Vector3D.of(1,0,0), TEST_PRECISION);
}
-
+
@Test(expected=IllegalNormException.class)
public void testFromPointAndNormalWithZeroNormal()
{
Plane.fromPointAndNormal(Vector3D.of(0, 0, 1), Vector3D.ZERO, TEST_PRECISION);
}
-
+
@Test(expected=IllegalNormException.class)
public void testFromNormal()
{
Plane.fromNormal(Vector3D.ZERO, TEST_PRECISION);
}
-
+
@Test
public void testIsParallelAndGetOffset()
{
@@ -95,10 +95,10 @@ public class PlaneTest {
Assert.assertFalse(plane.isParallel(nonParallelLine));
Assert.assertEquals(0.0, plane.getOffset(nonParallelLine), TEST_EPS);
}
-
+
@Test
public void testCreation()
- {
+ {
Vector3D normalAliasW = Vector3D.of(0, 0, 1);
Plane plane = Plane.fromPointAndNormal(Vector3D.of(0, 0, 1),normalAliasW , TEST_PRECISION);
Assert.assertEquals(normalAliasW, plane.getW());
@@ -110,7 +110,7 @@ public class PlaneTest {
Vector3D expectedOrigin = Vector3D.of(0, 0, 1);
Assert.assertEquals(expectedOrigin, plane.getOrigin());
}
-
+
@Test
public void testReverse()
{
@@ -124,7 +124,7 @@ public class PlaneTest {
Vector3D p1XYswapped = Vector3D.of(0,1,1);
Assert.assertTrue(reversePlane.contains(p1XYswapped));
}
-
+
@Test
public void testIsPlaneParallel()
{
@@ -136,7 +136,7 @@ public class PlaneTest {
Plane nonParallelPlane = Plane.fromPointAndPlaneVectors(Vector3D.of(0, 0, 1), Vector3D.of(1, 1.5, 1), Vector3D.of(0,1,1), TEST_PRECISION);
Assert.assertFalse(plane.isParallel(nonParallelPlane));
}
-
+
@Test
public void testProjectLine() {
Plane plane = Plane.fromPointAndNormal(Vector3D.of(0, 0, 1), Vector3D.of(0, 0, 1), TEST_PRECISION);
@@ -144,7 +144,7 @@ public class PlaneTest {
Line expectedProjection = new Line(Vector3D.of(1, 0, 1),Vector3D.of(2, 0, 1), TEST_PRECISION);
Assert.assertEquals(expectedProjection, plane.project(line));
}
-
+
@Test
public void testOffset() {
Vector3D p1 = Vector3D.of(1, 1, 1);
@@ -165,7 +165,7 @@ public class PlaneTest {
Plane.fromPointAndPlaneVectors(Vector3D.of(1, 1, 1), Vector3D.of(2, 0, 0), Vector3D.of(2,0,0), TEST_PRECISION);
}
-
+
@Test
public void testVectorsAreNormalizedForSuppliedUAndV() {
Plane plane = Plane.fromPointAndPlaneVectors(Vector3D.of(1, 1, 1), Vector3D.of(2, 0, 0), Vector3D.of(0,2,0), TEST_PRECISION);
@@ -174,8 +174,8 @@ public class PlaneTest {
Assert.assertEquals(1.0, plane.getU().norm(), TEST_EPS);
}
-
-
+
+
@Test
public void testVectorsAreNormalized() {
Plane plane = Plane.fromPointAndNormal(Vector3D.of(2, -3, 1), Vector3D.of(1, 4, 9), TEST_PRECISION);
@@ -184,7 +184,7 @@ public class PlaneTest {
Assert.assertEquals(1.0, plane.getU().norm(), TEST_EPS);
}
-
+
@Test
public void testPoint() {
Plane plane = Plane.fromPointAndNormal(Vector3D.of(2, -3, 1), Vector3D.of(1, 4, 9), TEST_PRECISION);