You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2014/01/01 18:22:54 UTC
svn commit: r1554646 - in /commons/proper/math/trunk/src:
main/java/org/apache/commons/math3/geometry/
main/java/org/apache/commons/math3/geometry/euclidean/oned/
main/java/org/apache/commons/math3/geometry/euclidean/threed/
main/java/org/apache/common...
Author: luc
Date: Wed Jan 1 17:22:53 2014
New Revision: 1554646
URL: http://svn.apache.org/r1554646
Log:
We don't need the full Vector API for BSP trees.
Added:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/Point.java (with props)
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/Vector.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/OrientedPoint.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Plane.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSet.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/Line.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/Vector2D.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/AbstractRegion.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/BSPTree.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Embedding.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Hyperplane.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Region.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Transform.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSetTest.java
Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/Point.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/Point.java?rev=1554646&view=auto
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/Point.java (added)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/Point.java Wed Jan 1 17:22:53 2014
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math3.geometry;
+
+import java.io.Serializable;
+
+/** This interface represents a generic geometrical point.
+ * @param <S> Type of the space.
+ * @version $Id$
+ * @see Space
+ * @see Vector
+ * @since 3.3
+ */
+public interface Point<S extends Space> extends Serializable {
+
+ /** Get the space to which the point belongs.
+ * @return containing space
+ */
+ Space getSpace();
+
+ /**
+ * Returns true if any coordinate of this point is NaN; false otherwise
+ * @return true if any coordinate of this point is NaN; false otherwise
+ */
+ boolean isNaN();
+
+}
Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/Point.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/Point.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/Vector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/Vector.java?rev=1554646&r1=1554645&r2=1554646&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/Vector.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/Vector.java Wed Jan 1 17:22:53 2014
@@ -16,7 +16,6 @@
*/
package org.apache.commons.math3.geometry;
-import java.io.Serializable;
import java.text.NumberFormat;
import org.apache.commons.math3.exception.MathArithmeticException;
@@ -25,15 +24,10 @@ import org.apache.commons.math3.exceptio
* @param <S> Type of the space.
* @version $Id$
* @see Space
- * @see Vector
+ * @see Point
* @since 3.0
*/
-public interface Vector<S extends Space> extends Serializable {
-
- /** Get the space to which the vector belongs.
- * @return containing space
- */
- Space getSpace();
+public interface Vector<S extends Space> extends Point<S> {
/** Get the null vector of the vectorial space or origin point of the affine space.
* @return null vector of the vectorial space or origin point of the affine space
@@ -104,12 +98,6 @@ public interface Vector<S extends Space>
Vector<S> scalarMultiply(double a);
/**
- * Returns true if any coordinate of this vector is NaN; false otherwise
- * @return true if any coordinate of this vector is NaN; false otherwise
- */
- boolean isNaN();
-
- /**
* Returns true if any coordinate of this vector is infinite and none are NaN;
* false otherwise
* @return true if any coordinate of this vector is infinite and none are NaN;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/OrientedPoint.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/OrientedPoint.java?rev=1554646&r1=1554645&r2=1554646&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/OrientedPoint.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/OrientedPoint.java Wed Jan 1 17:22:53 2014
@@ -16,7 +16,7 @@
*/
package org.apache.commons.math3.geometry.euclidean.oned;
-import org.apache.commons.math3.geometry.Vector;
+import org.apache.commons.math3.geometry.Point;
import org.apache.commons.math3.geometry.partitioning.Hyperplane;
/** This class represents a 1D oriented hyperplane.
@@ -54,7 +54,7 @@ public class OrientedPoint implements Hy
}
/** {@inheritDoc} */
- public double getOffset(final Vector<Euclidean1D> point) {
+ public double getOffset(final Point<Euclidean1D> point) {
final double delta = ((Vector1D) point).getX() - location.getX();
return direct ? delta : -delta;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java?rev=1554646&r1=1554645&r2=1554646&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java Wed Jan 1 17:22:53 2014
@@ -18,7 +18,7 @@ package org.apache.commons.math3.geometr
import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
-import org.apache.commons.math3.geometry.Vector;
+import org.apache.commons.math3.geometry.Point;
import org.apache.commons.math3.geometry.euclidean.oned.Euclidean1D;
import org.apache.commons.math3.geometry.euclidean.oned.IntervalsSet;
import org.apache.commons.math3.geometry.euclidean.oned.Vector1D;
@@ -125,14 +125,14 @@ public class Line implements Embedding<E
/** {@inheritDoc}
* @see #getAbscissa(Vector3D)
*/
- public Vector1D toSubSpace(final Vector<Euclidean3D> point) {
+ public Vector1D toSubSpace(final Point<Euclidean3D> point) {
return new Vector1D(getAbscissa((Vector3D) point));
}
/** {@inheritDoc}
* @see #pointAt(double)
*/
- public Vector3D toSpace(final Vector<Euclidean1D> point) {
+ public Vector3D toSpace(final Point<Euclidean1D> point) {
return pointAt(((Vector1D) point).getX());
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Plane.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Plane.java?rev=1554646&r1=1554645&r2=1554646&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Plane.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Plane.java Wed Jan 1 17:22:53 2014
@@ -18,7 +18,7 @@ package org.apache.commons.math3.geometr
import org.apache.commons.math3.exception.MathArithmeticException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
-import org.apache.commons.math3.geometry.Vector;
+import org.apache.commons.math3.geometry.Point;
import org.apache.commons.math3.geometry.euclidean.oned.Vector1D;
import org.apache.commons.math3.geometry.euclidean.twod.Euclidean2D;
import org.apache.commons.math3.geometry.euclidean.twod.PolygonsSet;
@@ -223,8 +223,9 @@ public class Plane implements Hyperplane
* org.apache.commons.math3.geometry.euclidean.twod.Vector2D Vector2D} instance)
* @see #toSpace
*/
- public Vector2D toSubSpace(final Vector<Euclidean3D> point) {
- return new Vector2D(point.dotProduct(u), point.dotProduct(v));
+ public Vector2D toSubSpace(final Point<Euclidean3D> point) {
+ final Vector3D p3D = (Vector3D) point;
+ return new Vector2D(p3D.dotProduct(u), p3D.dotProduct(v));
}
/** Transform an in-plane point into a 3D space point.
@@ -233,7 +234,7 @@ public class Plane implements Hyperplane
* @return 3D space point (really a {@link Vector3D Vector3D} instance)
* @see #toSubSpace
*/
- public Vector3D toSpace(final Vector<Euclidean2D> point) {
+ public Vector3D toSpace(final Point<Euclidean2D> point) {
final Vector2D p2D = (Vector2D) point;
return new Vector3D(p2D.getX(), u, p2D.getY(), v, -originOffset, w);
}
@@ -416,8 +417,8 @@ public class Plane implements Hyperplane
* @param point point to check
* @return offset of the point
*/
- public double getOffset(final Vector<Euclidean3D> point) {
- return point.dotProduct(w) + originOffset;
+ public double getOffset(final Point<Euclidean3D> point) {
+ return ((Vector3D) point).dotProduct(w) + originOffset;
}
/** Check if the instance has the same orientation as another hyperplane.
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSet.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSet.java?rev=1554646&r1=1554645&r2=1554646&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSet.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSet.java Wed Jan 1 17:22:53 2014
@@ -19,7 +19,7 @@ package org.apache.commons.math3.geometr
import java.awt.geom.AffineTransform;
import java.util.Collection;
-import org.apache.commons.math3.geometry.Vector;
+import org.apache.commons.math3.geometry.Point;
import org.apache.commons.math3.geometry.euclidean.oned.Euclidean1D;
import org.apache.commons.math3.geometry.euclidean.twod.Euclidean2D;
import org.apache.commons.math3.geometry.euclidean.twod.SubLine;
@@ -340,7 +340,7 @@ public class PolyhedronsSet extends Abst
}
/** {@inheritDoc} */
- public Vector3D apply(final Vector<Euclidean3D> point) {
+ public Vector3D apply(final Point<Euclidean3D> point) {
final Vector3D delta = ((Vector3D) point).subtract(center);
return new Vector3D(1.0, center, 1.0, rotation.applyTo(delta));
}
@@ -408,7 +408,7 @@ public class PolyhedronsSet extends Abst
}
/** {@inheritDoc} */
- public Vector3D apply(final Vector<Euclidean3D> point) {
+ public Vector3D apply(final Point<Euclidean3D> point) {
return new Vector3D(1.0, (Vector3D) point, 1.0, translation);
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/Line.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/Line.java?rev=1554646&r1=1554645&r2=1554646&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/Line.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/Line.java Wed Jan 1 17:22:53 2014
@@ -20,7 +20,7 @@ import java.awt.geom.AffineTransform;
import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
-import org.apache.commons.math3.geometry.Vector;
+import org.apache.commons.math3.geometry.Point;
import org.apache.commons.math3.geometry.euclidean.oned.Euclidean1D;
import org.apache.commons.math3.geometry.euclidean.oned.IntervalsSet;
import org.apache.commons.math3.geometry.euclidean.oned.OrientedPoint;
@@ -177,13 +177,13 @@ public class Line implements Hyperplane<
}
/** {@inheritDoc} */
- public Vector1D toSubSpace(final Vector<Euclidean2D> point) {
+ public Vector1D toSubSpace(final Point<Euclidean2D> point) {
Vector2D p2 = (Vector2D) point;
return new Vector1D(cos * p2.getX() + sin * p2.getY());
}
/** {@inheritDoc} */
- public Vector2D toSpace(final Vector<Euclidean1D> point) {
+ public Vector2D toSpace(final Point<Euclidean1D> point) {
final double abscissa = ((Vector1D) point).getX();
return new Vector2D(abscissa * cos - originOffset * sin,
abscissa * sin + originOffset * cos);
@@ -232,7 +232,7 @@ public class Line implements Hyperplane<
}
/** {@inheritDoc} */
- public double getOffset(final Vector<Euclidean2D> point) {
+ public double getOffset(final Point<Euclidean2D> point) {
Vector2D p2 = (Vector2D) point;
return sin * p2.getX() - cos * p2.getY() + originOffset;
}
@@ -390,7 +390,7 @@ public class Line implements Hyperplane<
}
/** {@inheritDoc} */
- public Vector2D apply(final Vector<Euclidean2D> point) {
+ public Vector2D apply(final Point<Euclidean2D> point) {
final Vector2D p2D = (Vector2D) point;
final double x = p2D.getX();
final double y = p2D.getY();
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/Vector2D.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/Vector2D.java?rev=1554646&r1=1554645&r2=1554646&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/Vector2D.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/Vector2D.java Wed Jan 1 17:22:53 2014
@@ -24,6 +24,7 @@ import org.apache.commons.math3.exceptio
import org.apache.commons.math3.geometry.Space;
import org.apache.commons.math3.geometry.Vector;
import org.apache.commons.math3.util.FastMath;
+import org.apache.commons.math3.util.MathArrays;
import org.apache.commons.math3.util.MathUtils;
/** This class represents a 2D vector.
@@ -228,6 +229,41 @@ public class Vector2D implements Vector<
}
return scalarMultiply(1 / s);
}
+
+ /** Compute the angular separation between two vectors.
+ * <p>This method computes the angular separation between two
+ * vectors using the dot product for well separated vectors and the
+ * cross product for almost aligned vectors. This allows to have a
+ * good accuracy in all cases, even for vectors very close to each
+ * other.</p>
+ * @param v1 first vector
+ * @param v2 second vector
+ * @return angular separation between v1 and v2
+ * @exception MathArithmeticException if either vector has a null norm
+ */
+ public static double angle(Vector2D v1, Vector2D v2) throws MathArithmeticException {
+
+ double normProduct = v1.getNorm() * v2.getNorm();
+ if (normProduct == 0) {
+ throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
+ }
+
+ double dot = v1.dotProduct(v2);
+ double threshold = normProduct * 0.9999;
+ if ((dot < -threshold) || (dot > threshold)) {
+ // the vectors are almost aligned, compute using the sine
+ final double n = FastMath.abs(MathArrays.linearCombination(v1.x, v2.y, -v1.y, v2.x));
+ if (dot >= 0) {
+ return FastMath.asin(n / normProduct);
+ }
+ return FastMath.PI - FastMath.asin(n / normProduct);
+ }
+
+ // the vectors are sufficiently separated to use the cosine
+ return FastMath.acos(dot / normProduct);
+
+ }
+
/** {@inheritDoc} */
public Vector2D negate() {
return new Vector2D(-x, -y);
@@ -283,7 +319,7 @@ public class Vector2D implements Vector<
/** {@inheritDoc} */
public double dotProduct(final Vector<Euclidean2D> v) {
final Vector2D v2 = (Vector2D) v;
- return x * v2.x + y * v2.y;
+ return MathArrays.linearCombination(x, v2.x, y, v2.y);
}
/** Compute the distance between two vectors according to the L<sub>2</sub> norm.
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/AbstractRegion.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/AbstractRegion.java?rev=1554646&r1=1554645&r2=1554646&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/AbstractRegion.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/AbstractRegion.java Wed Jan 1 17:22:53 2014
@@ -25,7 +25,7 @@ import java.util.TreeSet;
import org.apache.commons.math3.exception.MathInternalError;
import org.apache.commons.math3.geometry.Space;
-import org.apache.commons.math3.geometry.Vector;
+import org.apache.commons.math3.geometry.Point;
/** Abstract class for all regions, independently of geometry type or dimension.
@@ -44,7 +44,7 @@ public abstract class AbstractRegion<S e
private double size;
/** Barycenter. */
- private Vector<S> barycenter;
+ private Point<S> barycenter;
/** Build a region representing the whole space.
*/
@@ -80,7 +80,7 @@ public abstract class AbstractRegion<S e
* (their topological connections are not used here). However, if the
* boundary does not really separate an inside open from an outside
* open (open having here its topological meaning), then subsequent
- * calls to the {@link #checkPoint(Vector) checkPoint} method will not be
+ * calls to the {@link #checkPoint(Point) checkPoint} method will not be
* meaningful anymore.</p>
* <p>If the boundary is empty, the region will represent the whole
* space.</p>
@@ -250,7 +250,7 @@ public abstract class AbstractRegion<S e
}
/** {@inheritDoc} */
- public Location checkPoint(final Vector<S> point) {
+ public Location checkPoint(final Point<S> point) {
return checkPoint(tree, point);
}
@@ -261,7 +261,7 @@ public abstract class AbstractRegion<S e
* Region.Location#INSIDE INSIDE}, {@link Region.Location#OUTSIDE
* OUTSIDE} or {@link Region.Location#BOUNDARY BOUNDARY}
*/
- protected Location checkPoint(final BSPTree<S> node, final Vector<S> point) {
+ protected Location checkPoint(final BSPTree<S> node, final Point<S> point) {
final BSPTree<S> cell = node.getCell(point);
if (cell.getCut() == null) {
// the point is in the interior of a cell, just check the attribute
@@ -423,7 +423,7 @@ public abstract class AbstractRegion<S e
}
/** {@inheritDoc} */
- public Vector<S> getBarycenter() {
+ public Point<S> getBarycenter() {
if (barycenter == null) {
computeGeometricalProperties();
}
@@ -433,7 +433,7 @@ public abstract class AbstractRegion<S e
/** Set the barycenter of the instance.
* @param barycenter barycenter of the instance
*/
- protected void setBarycenter(final Vector<S> barycenter) {
+ protected void setBarycenter(final Point<S> barycenter) {
this.barycenter = barycenter;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/BSPTree.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/BSPTree.java?rev=1554646&r1=1554645&r2=1554646&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/BSPTree.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/BSPTree.java Wed Jan 1 17:22:53 2014
@@ -17,7 +17,7 @@
package org.apache.commons.math3.geometry.partitioning;
import org.apache.commons.math3.exception.MathInternalError;
-import org.apache.commons.math3.geometry.Vector;
+import org.apache.commons.math3.geometry.Point;
import org.apache.commons.math3.geometry.Space;
import org.apache.commons.math3.util.FastMath;
@@ -307,7 +307,7 @@ public class BSPTree<S extends Space> {
* @param point point to check
* @return the tree cell to which the point belongs (can be
*/
- public BSPTree<S> getCell(final Vector<S> point) {
+ public BSPTree<S> getCell(final Point<S> point) {
if (cut == null) {
return this;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Embedding.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Embedding.java?rev=1554646&r1=1554645&r2=1554646&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Embedding.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Embedding.java Wed Jan 1 17:22:53 2014
@@ -16,7 +16,7 @@
*/
package org.apache.commons.math3.geometry.partitioning;
-import org.apache.commons.math3.geometry.Vector;
+import org.apache.commons.math3.geometry.Point;
import org.apache.commons.math3.geometry.Space;
/** This interface defines mappers between a space and one of its sub-spaces.
@@ -49,7 +49,7 @@ public interface Embedding<S extends Spa
* the specified space point
* @see #toSpace
*/
- Vector<T> toSubSpace(Vector<S> point);
+ Point<T> toSubSpace(Point<S> point);
/** Transform a sub-space point into a space point.
* @param point (n-1)-dimension point of the sub-space
@@ -57,6 +57,6 @@ public interface Embedding<S extends Spa
* specified sub-space point
* @see #toSubSpace
*/
- Vector<S> toSpace(Vector<T> point);
+ Point<S> toSpace(Point<T> point);
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Hyperplane.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Hyperplane.java?rev=1554646&r1=1554645&r2=1554646&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Hyperplane.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Hyperplane.java Wed Jan 1 17:22:53 2014
@@ -16,7 +16,7 @@
*/
package org.apache.commons.math3.geometry.partitioning;
-import org.apache.commons.math3.geometry.Vector;
+import org.apache.commons.math3.geometry.Point;
import org.apache.commons.math3.geometry.Space;
/** This interface represents an hyperplane of a space.
@@ -53,7 +53,7 @@ public interface Hyperplane<S extends Sp
* @param point point to check
* @return offset of the point
*/
- double getOffset(Vector<S> point);
+ double getOffset(Point<S> point);
/** Check if the instance has the same orientation as another hyperplane.
* <p>This method is expected to be called on parallel hyperplanes. The
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Region.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Region.java?rev=1554646&r1=1554645&r2=1554646&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Region.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Region.java Wed Jan 1 17:22:53 2014
@@ -17,7 +17,7 @@
package org.apache.commons.math3.geometry.partitioning;
import org.apache.commons.math3.geometry.Space;
-import org.apache.commons.math3.geometry.Vector;
+import org.apache.commons.math3.geometry.Point;
/** This interface represents a region of a space as a partition.
@@ -110,7 +110,7 @@ public interface Region<S extends Space>
* @return a code representing the point status: either {@link
* Location#INSIDE}, {@link Location#OUTSIDE} or {@link Location#BOUNDARY}
*/
- Location checkPoint(final Vector<S> point);
+ Location checkPoint(final Point<S> point);
/** Get the underlying BSP tree.
@@ -168,7 +168,7 @@ public interface Region<S extends Space>
/** Get the barycenter of the instance.
* @return an object representing the barycenter
*/
- Vector<S> getBarycenter();
+ Point<S> getBarycenter();
/** Compute the relative position of the instance with respect to an
* hyperplane.
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Transform.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Transform.java?rev=1554646&r1=1554645&r2=1554646&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Transform.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/partitioning/Transform.java Wed Jan 1 17:22:53 2014
@@ -16,7 +16,7 @@
*/
package org.apache.commons.math3.geometry.partitioning;
-import org.apache.commons.math3.geometry.Vector;
+import org.apache.commons.math3.geometry.Point;
import org.apache.commons.math3.geometry.Space;
@@ -30,7 +30,7 @@ import org.apache.commons.math3.geometry
* <ul>
* <li>
* the transform can be applied to a point in the
- * D-dimension space using its {@link #apply(Vector)}
+ * D-dimension space using its {@link #apply(Point)}
* method
* </li>
* <li>
@@ -58,7 +58,7 @@ public interface Transform<S extends Spa
* @param point point to transform
* @return a new object representing the transformed point
*/
- Vector<S> apply(Vector<S> point);
+ Point<S> apply(Point<S> point);
/** Transform an hyperplane of a space.
* @param hyperplane hyperplane to transform
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSetTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSetTest.java?rev=1554646&r1=1554645&r2=1554646&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSetTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSetTest.java Wed Jan 1 17:22:53 2014
@@ -20,6 +20,7 @@ import java.util.ArrayList;
import org.apache.commons.math3.exception.MathArithmeticException;
import org.apache.commons.math3.exception.MathIllegalArgumentException;
+import org.apache.commons.math3.geometry.Vector;
import org.apache.commons.math3.geometry.euclidean.twod.Euclidean2D;
import org.apache.commons.math3.geometry.euclidean.twod.PolygonsSet;
import org.apache.commons.math3.geometry.euclidean.twod.SubLine;
@@ -135,7 +136,7 @@ public class PolyhedronsSetTest {
1.0, c,
1.0, r.applyTo(barycenter.subtract(c)));
Assert.assertEquals(0.0,
- newB.subtract(tree.getBarycenter()).getNorm(),
+ newB.subtract((Vector<Euclidean3D>) tree.getBarycenter()).getNorm(),
1.0e-10);
final Vector3D[] expectedV = new Vector3D[] {