Fixed some Clirr errors.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1554651 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a3e4cbe0bb
commit
ed73c356c7
|
@ -38,4 +38,10 @@ public interface Point<S extends Space> extends Serializable {
|
|||
*/
|
||||
boolean isNaN();
|
||||
|
||||
/** Compute the distance between the instance and another point.
|
||||
* @param p second point
|
||||
* @return the distance between the instance and p
|
||||
*/
|
||||
double distance(Point<S> p);
|
||||
|
||||
}
|
||||
|
|
|
@ -120,7 +120,9 @@ public interface Vector<S extends Space> extends Point<S> {
|
|||
* vector is built</p>
|
||||
* @param v second vector
|
||||
* @return the distance between the instance and p according to the L<sub>2</sub> norm
|
||||
* @deprecated as of 3.3 replaced with {@link Point#distance(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
double distance(Vector<S> v);
|
||||
|
||||
/** Compute the distance between the instance and another vector according to the L<sub>∞</sub> norm.
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
import org.apache.commons.math3.geometry.partitioning.AbstractRegion;
|
||||
import org.apache.commons.math3.geometry.partitioning.BSPTree;
|
||||
import org.apache.commons.math3.geometry.partitioning.SubHyperplane;
|
||||
|
@ -73,7 +74,7 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> {
|
|||
* boundary does not really separate an inside open from an outside
|
||||
* open (open having here its topological meaning), then subsequent
|
||||
* calls to the {@link
|
||||
* org.apache.commons.math3.geometry.partitioning.Region#checkPoint(org.apache.commons.math3.geometry.Vector)
|
||||
* org.apache.commons.math3.geometry.partitioning.Region#checkPoint(org.apache.commons.math3.geometry.Point)
|
||||
* checkPoint} method will not be meaningful anymore.</p>
|
||||
* <p>If the boundary is empty, the region will represent the whole
|
||||
* space.</p>
|
||||
|
@ -137,7 +138,7 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> {
|
|||
@Override
|
||||
protected void computeGeometricalProperties() {
|
||||
if (getTree(false).getCut() == null) {
|
||||
setBarycenter(Vector1D.NaN);
|
||||
setBarycenter((Point<Euclidean1D>) Vector1D.NaN);
|
||||
setSize(((Boolean) getTree(false).getAttribute()) ? Double.POSITIVE_INFINITY : 0);
|
||||
} else {
|
||||
double size = 0.0;
|
||||
|
@ -148,11 +149,11 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> {
|
|||
}
|
||||
setSize(size);
|
||||
if (Double.isInfinite(size)) {
|
||||
setBarycenter(Vector1D.NaN);
|
||||
setBarycenter((Point<Euclidean1D>) Vector1D.NaN);
|
||||
} else if (size >= Precision.SAFE_MIN) {
|
||||
setBarycenter(new Vector1D(sum / size));
|
||||
setBarycenter((Point<Euclidean1D>) new Vector1D(sum / size));
|
||||
} else {
|
||||
setBarycenter(((OrientedPoint) getTree(false).getCut().getHyperplane()).getLocation());
|
||||
setBarycenter((Point<Euclidean1D>) ((OrientedPoint) getTree(false).getCut().getHyperplane()).getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -238,8 +239,8 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> {
|
|||
op.isDirect() ? node.getPlus() : node.getMinus();
|
||||
|
||||
recurseList(low, list, lower, x);
|
||||
if ((checkPoint(low, loc) == Location.INSIDE) &&
|
||||
(checkPoint(high, loc) == Location.INSIDE)) {
|
||||
if ((checkPoint(low, (Point<Euclidean1D>) loc) == Location.INSIDE) &&
|
||||
(checkPoint(high, (Point<Euclidean1D>) loc) == Location.INSIDE)) {
|
||||
// merge the last interval added and the first one of the high sub-tree
|
||||
x = list.remove(list.size() - 1).getInf();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.commons.math3.geometry.euclidean.oned;
|
||||
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
import org.apache.commons.math3.geometry.Vector;
|
||||
import org.apache.commons.math3.geometry.partitioning.Hyperplane;
|
||||
|
||||
/** This class represents a 1D oriented hyperplane.
|
||||
|
@ -53,6 +54,16 @@ public class OrientedPoint implements Hyperplane<Euclidean1D> {
|
|||
return this;
|
||||
}
|
||||
|
||||
/** Get the offset (oriented distance) of a vector.
|
||||
* @param vector vector to check
|
||||
* @return offset of the vector
|
||||
* @deprecated as of 3.3, replaced with {@link #getOffset(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
public double getOffset(Vector<Euclidean1D> vector) {
|
||||
return getOffset((Point<Euclidean1D>) vector);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public double getOffset(final Point<Euclidean1D> point) {
|
||||
final double delta = ((Vector1D) point).getX() - location.getX();
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.text.NumberFormat;
|
|||
|
||||
import org.apache.commons.math3.exception.MathArithmeticException;
|
||||
import org.apache.commons.math3.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
import org.apache.commons.math3.geometry.Space;
|
||||
import org.apache.commons.math3.geometry.Vector;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
|
@ -217,8 +218,16 @@ public class Vector1D implements Vector<Euclidean1D> {
|
|||
return dx;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.3, replaced with {@link #distance(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
public double distance(Vector<Euclidean1D> p) {
|
||||
return distance((Point<Euclidean1D>) p);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public double distance(Point<Euclidean1D> p) {
|
||||
Vector1D p3 = (Vector1D) p;
|
||||
final double dx = p3.x - x;
|
||||
return FastMath.abs(dx);
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.commons.math3.geometry.euclidean.threed;
|
|||
import org.apache.commons.math3.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math3.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
import org.apache.commons.math3.geometry.Vector;
|
||||
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;
|
||||
|
@ -122,6 +123,28 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
|
|||
return new Vector3D(1.0, zero, abscissa, direction);
|
||||
}
|
||||
|
||||
/** Transform a space point into a sub-space point.
|
||||
* @param vector n-dimension point of the space
|
||||
* @return (n-1)-dimension point of the sub-space corresponding to
|
||||
* the specified space point
|
||||
* @deprecated as of 3.3, replaced with {@link #toSubSpace(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Vector1D toSubSpace(Vector<Euclidean3D> vector) {
|
||||
return toSubSpace((Point<Euclidean3D>) vector);
|
||||
}
|
||||
|
||||
/** Transform a sub-space point into a space point.
|
||||
* @param vector (n-1)-dimension point of the sub-space
|
||||
* @return n-dimension point of the space corresponding to the
|
||||
* specified sub-space point
|
||||
* @deprecated as of 3.3, replaced with {@link #toSpace(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Vector3D toSpace(Vector<Euclidean1D> vector) {
|
||||
return toSpace((Point<Euclidean1D>) vector);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
* @see #getAbscissa(Vector3D)
|
||||
*/
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.commons.math3.geometry.euclidean.threed;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
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.Vector2D;
|
||||
|
@ -199,13 +200,13 @@ public class OutlineExtractor {
|
|||
for (Vector2D[] loop : vertices) {
|
||||
final boolean closed = loop[0] != null;
|
||||
int previous = closed ? (loop.length - 1) : 1;
|
||||
Vector3D previous3D = plane.toSpace(loop[previous]);
|
||||
Vector3D previous3D = plane.toSpace((Point<Euclidean2D>) loop[previous]);
|
||||
int current = (previous + 1) % loop.length;
|
||||
Vector2D pPoint = new Vector2D(previous3D.dotProduct(u),
|
||||
previous3D.dotProduct(v));
|
||||
while (current < loop.length) {
|
||||
|
||||
final Vector3D current3D = plane.toSpace(loop[current]);
|
||||
final Vector3D current3D = plane.toSpace((Point<Euclidean2D>) loop[current]);
|
||||
final Vector2D cPoint = new Vector2D(current3D.dotProduct(u),
|
||||
current3D.dotProduct(v));
|
||||
final org.apache.commons.math3.geometry.euclidean.twod.Line line =
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.commons.math3.geometry.euclidean.threed;
|
|||
import org.apache.commons.math3.exception.MathArithmeticException;
|
||||
import org.apache.commons.math3.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
import org.apache.commons.math3.geometry.Vector;
|
||||
import org.apache.commons.math3.geometry.euclidean.oned.Euclidean1D;
|
||||
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;
|
||||
|
@ -216,6 +218,28 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
|
|||
originOffset = -originOffset;
|
||||
}
|
||||
|
||||
/** Transform a space point into a sub-space point.
|
||||
* @param vector n-dimension point of the space
|
||||
* @return (n-1)-dimension point of the sub-space corresponding to
|
||||
* the specified space point
|
||||
* @deprecated as of 3.3, replaced with {@link #toSubSpace(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Vector2D toSubSpace(Vector<Euclidean3D> vector) {
|
||||
return toSubSpace((Point<Euclidean3D>) vector);
|
||||
}
|
||||
|
||||
/** Transform a sub-space point into a space point.
|
||||
* @param vector (n-1)-dimension point of the sub-space
|
||||
* @return n-dimension point of the space corresponding to the
|
||||
* specified sub-space point
|
||||
* @deprecated as of 3.3, replaced with {@link #toSpace(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Vector3D toSpace(Vector<Euclidean2D> vector) {
|
||||
return toSpace((Point<Euclidean2D>) vector);
|
||||
}
|
||||
|
||||
/** Transform a 3D space point into an in-plane point.
|
||||
* @param point point of the space (must be a {@link Vector3D
|
||||
* Vector3D} instance)
|
||||
|
@ -311,7 +335,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
|
|||
if (FastMath.abs(dot) < 1.0e-10) {
|
||||
return null;
|
||||
}
|
||||
final Vector3D point = line.toSpace(Vector1D.ZERO);
|
||||
final Vector3D point = line.toSpace((Point<Euclidean1D>) Vector1D.ZERO);
|
||||
final double k = -(originOffset + w.dotProduct(point)) / dot;
|
||||
return new Vector3D(1.0, point, k, direction);
|
||||
}
|
||||
|
@ -409,6 +433,16 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
|
|||
return originOffset + (sameOrientationAs(plane) ? -plane.originOffset : plane.originOffset);
|
||||
}
|
||||
|
||||
/** Get the offset (oriented distance) of a vector.
|
||||
* @param vector vector to check
|
||||
* @return offset of the vector
|
||||
* @deprecated as of 3.3, replaced with {@link #getOffset(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
public double getOffset(Vector<Euclidean3D> vector) {
|
||||
return getOffset((Point<Euclidean3D>) vector);
|
||||
}
|
||||
|
||||
/** Get the offset (oriented distance) of a point.
|
||||
* <p>The offset is 0 if the point is on the underlying hyperplane,
|
||||
* it is positive if the point is on one particular side of the
|
||||
|
|
|
@ -72,7 +72,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
|
|||
* (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 Region#checkPoint(Vector) checkPoint} method will
|
||||
* calls to the {@link Region#checkPoint(Point) checkPoint} method will
|
||||
* not be meaningful anymore.</p>
|
||||
* <p>If the boundary is empty, the region will represent the whole
|
||||
* space.</p>
|
||||
|
@ -138,11 +138,11 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
|
|||
// the polyhedrons set as a finite outside
|
||||
// surrounded by an infinite inside
|
||||
setSize(Double.POSITIVE_INFINITY);
|
||||
setBarycenter(Vector3D.NaN);
|
||||
setBarycenter((Point<Euclidean3D>) Vector3D.NaN);
|
||||
} else {
|
||||
// the polyhedrons set is finite, apply the remaining scaling factors
|
||||
setSize(getSize() / 3.0);
|
||||
setBarycenter(new Vector3D(1.0 / (4 * getSize()), (Vector3D) getBarycenter()));
|
||||
setBarycenter((Point<Euclidean3D>) new Vector3D(1.0 / (4 * getSize()), (Vector3D) getBarycenter()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
|
|||
/** Simple constructor. */
|
||||
public FacetsContributionVisitor() {
|
||||
setSize(0);
|
||||
setBarycenter(new Vector3D(0, 0, 0));
|
||||
setBarycenter((Point<Euclidean3D>) new Vector3D(0, 0, 0));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -189,7 +189,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
|
|||
|
||||
if (Double.isInfinite(area)) {
|
||||
setSize(Double.POSITIVE_INFINITY);
|
||||
setBarycenter(Vector3D.NaN);
|
||||
setBarycenter((Point<Euclidean3D>) Vector3D.NaN);
|
||||
} else {
|
||||
|
||||
final Plane plane = (Plane) facet.getHyperplane();
|
||||
|
@ -200,7 +200,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
|
|||
}
|
||||
|
||||
setSize(getSize() + scaled);
|
||||
setBarycenter(new Vector3D(1.0, (Vector3D) getBarycenter(), scaled, facetB));
|
||||
setBarycenter((Point<Euclidean3D>) new Vector3D(1.0, (Vector3D) getBarycenter(), scaled, facetB));
|
||||
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
|
|||
final Plane plane = (Plane) cut.getHyperplane();
|
||||
|
||||
// establish search order
|
||||
final double offset = plane.getOffset(point);
|
||||
final double offset = plane.getOffset((Point<Euclidean3D>) point);
|
||||
final boolean in = FastMath.abs(offset) < 1.0e-10;
|
||||
final BSPTree<Euclidean3D> near;
|
||||
final BSPTree<Euclidean3D> far;
|
||||
|
@ -290,7 +290,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
|
|||
*/
|
||||
private SubHyperplane<Euclidean3D> boundaryFacet(final Vector3D point,
|
||||
final BSPTree<Euclidean3D> node) {
|
||||
final Vector2D point2D = ((Plane) node.getCut().getHyperplane()).toSubSpace(point);
|
||||
final Vector2D point2D = ((Plane) node.getCut().getHyperplane()).toSubSpace((Point<Euclidean3D>) point);
|
||||
@SuppressWarnings("unchecked")
|
||||
final BoundaryAttribute<Euclidean3D> attribute =
|
||||
(BoundaryAttribute<Euclidean3D>) node.getAttribute();
|
||||
|
@ -360,11 +360,11 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
|
|||
final Plane oPlane = (Plane) original;
|
||||
final Plane tPlane = (Plane) transformed;
|
||||
final Vector3D p00 = oPlane.getOrigin();
|
||||
final Vector3D p10 = oPlane.toSpace(new Vector2D(1.0, 0.0));
|
||||
final Vector3D p01 = oPlane.toSpace(new Vector2D(0.0, 1.0));
|
||||
final Vector2D tP00 = tPlane.toSubSpace(apply(p00));
|
||||
final Vector2D tP10 = tPlane.toSubSpace(apply(p10));
|
||||
final Vector2D tP01 = tPlane.toSubSpace(apply(p01));
|
||||
final Vector3D p10 = oPlane.toSpace((Point<Euclidean2D>) new Vector2D(1.0, 0.0));
|
||||
final Vector3D p01 = oPlane.toSpace((Point<Euclidean2D>) new Vector2D(0.0, 1.0));
|
||||
final Vector2D tP00 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p00));
|
||||
final Vector2D tP10 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p10));
|
||||
final Vector2D tP01 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p01));
|
||||
final AffineTransform at =
|
||||
new AffineTransform(tP10.getX() - tP00.getX(), tP10.getY() - tP00.getY(),
|
||||
tP01.getX() - tP00.getX(), tP01.getY() - tP00.getY(),
|
||||
|
@ -426,7 +426,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
|
|||
|
||||
final Plane oPlane = (Plane) original;
|
||||
final Plane tPlane = (Plane) transformed;
|
||||
final Vector2D shift = tPlane.toSubSpace(apply(oPlane.getOrigin()));
|
||||
final Vector2D shift = tPlane.toSubSpace((Point<Euclidean3D>) apply(oPlane.getOrigin()));
|
||||
final AffineTransform at =
|
||||
AffineTransform.getTranslateInstance(shift.getX(), shift.getY());
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.math3.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
import org.apache.commons.math3.geometry.euclidean.oned.Euclidean1D;
|
||||
import org.apache.commons.math3.geometry.euclidean.oned.Interval;
|
||||
import org.apache.commons.math3.geometry.euclidean.oned.IntervalsSet;
|
||||
import org.apache.commons.math3.geometry.euclidean.oned.Vector1D;
|
||||
|
@ -84,8 +86,8 @@ public class SubLine {
|
|||
final List<Segment> segments = new ArrayList<Segment>(list.size());
|
||||
|
||||
for (final Interval interval : list) {
|
||||
final Vector3D start = line.toSpace(new Vector1D(interval.getInf()));
|
||||
final Vector3D end = line.toSpace(new Vector1D(interval.getSup()));
|
||||
final Vector3D start = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getInf()));
|
||||
final Vector3D end = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getSup()));
|
||||
segments.add(new Segment(start, end, line));
|
||||
}
|
||||
|
||||
|
@ -116,10 +118,10 @@ public class SubLine {
|
|||
}
|
||||
|
||||
// check location of point with respect to first sub-line
|
||||
Location loc1 = remainingRegion.checkPoint(line.toSubSpace(v1D));
|
||||
Location loc1 = remainingRegion.checkPoint((Point<Euclidean1D>) line.toSubSpace((Point<Euclidean3D>) v1D));
|
||||
|
||||
// check location of point with respect to second sub-line
|
||||
Location loc2 = subLine.remainingRegion.checkPoint(subLine.line.toSubSpace(v1D));
|
||||
Location loc2 = subLine.remainingRegion.checkPoint((Point<Euclidean1D>) subLine.line.toSubSpace((Point<Euclidean3D>) v1D));
|
||||
|
||||
if (includeEndPoints) {
|
||||
return ((loc1 != Location.OUTSIDE) && (loc2 != Location.OUTSIDE)) ? v1D : null;
|
||||
|
@ -138,8 +140,8 @@ public class SubLine {
|
|||
private static IntervalsSet buildIntervalSet(final Vector3D start, final Vector3D end)
|
||||
throws MathIllegalArgumentException {
|
||||
final Line line = new Line(start, end);
|
||||
return new IntervalsSet(line.toSubSpace(start).getX(),
|
||||
line.toSubSpace(end).getX());
|
||||
return new IntervalsSet(line.toSubSpace((Point<Euclidean3D>) start).getX(),
|
||||
line.toSubSpace((Point<Euclidean3D>) end).getX());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.commons.math3.geometry.euclidean.threed;
|
||||
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
import org.apache.commons.math3.geometry.euclidean.oned.Euclidean1D;
|
||||
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.Vector2D;
|
||||
|
@ -71,8 +73,8 @@ public class SubPlane extends AbstractSubHyperplane<Euclidean3D, Euclidean2D> {
|
|||
// (i.e. the 3D half space on the plus side (resp. minus side)
|
||||
// of the instance contains the 2D half plane on the plus side
|
||||
// (resp. minus side) of the 2D line
|
||||
Vector2D p = thisPlane.toSubSpace(inter.toSpace(Vector1D.ZERO));
|
||||
Vector2D q = thisPlane.toSubSpace(inter.toSpace(Vector1D.ONE));
|
||||
Vector2D p = thisPlane.toSubSpace((Point<Euclidean3D>) inter.toSpace((Point<Euclidean1D>) Vector1D.ZERO));
|
||||
Vector2D q = thisPlane.toSubSpace((Point<Euclidean3D>) inter.toSpace((Point<Euclidean1D>) Vector1D.ONE));
|
||||
Vector3D crossP = Vector3D.crossProduct(inter.getDirection(), thisPlane.getNormal());
|
||||
if (crossP.dotProduct(otherPlane.getNormal()) < 0) {
|
||||
final Vector2D tmp = p;
|
||||
|
@ -109,8 +111,8 @@ public class SubPlane extends AbstractSubHyperplane<Euclidean3D, Euclidean2D> {
|
|||
}
|
||||
|
||||
// the hyperplanes do intersect
|
||||
Vector2D p = thisPlane.toSubSpace(inter.toSpace(Vector1D.ZERO));
|
||||
Vector2D q = thisPlane.toSubSpace(inter.toSpace(Vector1D.ONE));
|
||||
Vector2D p = thisPlane.toSubSpace((Point<Euclidean3D>) inter.toSpace((Point<Euclidean1D>) Vector1D.ZERO));
|
||||
Vector2D q = thisPlane.toSubSpace((Point<Euclidean3D>) inter.toSpace((Point<Euclidean1D>) Vector1D.ONE));
|
||||
Vector3D crossP = Vector3D.crossProduct(inter.getDirection(), thisPlane.getNormal());
|
||||
if (crossP.dotProduct(otherPlane.getNormal()) < 0) {
|
||||
final Vector2D tmp = p;
|
||||
|
|
|
@ -23,11 +23,12 @@ import java.text.NumberFormat;
|
|||
import org.apache.commons.math3.exception.DimensionMismatchException;
|
||||
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.Space;
|
||||
import org.apache.commons.math3.geometry.Vector;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.apache.commons.math3.util.MathUtils;
|
||||
import org.apache.commons.math3.util.MathArrays;
|
||||
import org.apache.commons.math3.util.MathUtils;
|
||||
|
||||
/**
|
||||
* This class implements vectors in a three-dimensional space.
|
||||
|
@ -474,8 +475,16 @@ public class Vector3D implements Serializable, Vector<Euclidean3D> {
|
|||
return dx + dy + dz;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.3, replaced with {@link #distance(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
public double distance(Vector<Euclidean3D> v) {
|
||||
return distance((Point<Euclidean3D>) v);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public double distance(Point<Euclidean3D> v) {
|
||||
final Vector3D v3 = (Vector3D) v;
|
||||
final double dx = v3.x - x;
|
||||
final double dy = v3.y - y;
|
||||
|
|
|
@ -21,6 +21,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.Point;
|
||||
import org.apache.commons.math3.geometry.Vector;
|
||||
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;
|
||||
|
@ -176,6 +177,28 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
|
|||
-cos, -sin, -originOffset);
|
||||
}
|
||||
|
||||
/** Transform a space point into a sub-space point.
|
||||
* @param vector n-dimension point of the space
|
||||
* @return (n-1)-dimension point of the sub-space corresponding to
|
||||
* the specified space point
|
||||
* @deprecated as of 3.3, replaced with {@link #toSubSpace(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Vector1D toSubSpace(Vector<Euclidean2D> vector) {
|
||||
return toSubSpace((Point<Euclidean2D>) vector);
|
||||
}
|
||||
|
||||
/** Transform a sub-space point into a space point.
|
||||
* @param vector (n-1)-dimension point of the sub-space
|
||||
* @return n-dimension point of the space corresponding to the
|
||||
* specified sub-space point
|
||||
* @deprecated as of 3.3, replaced with {@link #toSpace(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Vector2D toSpace(Vector<Euclidean1D> vector) {
|
||||
return toSpace((Point<Euclidean1D>) vector);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Vector1D toSubSpace(final Point<Euclidean2D> point) {
|
||||
Vector2D p2 = (Vector2D) point;
|
||||
|
@ -231,6 +254,16 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
|
|||
((cos * line.cos + sin * line.sin > 0) ? -line.originOffset : line.originOffset);
|
||||
}
|
||||
|
||||
/** Get the offset (oriented distance) of a vector.
|
||||
* @param vector vector to check
|
||||
* @return offset of the vector
|
||||
* @deprecated as of 3.3, replaced with {@link #getOffset(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
public double getOffset(Vector<Euclidean2D> vector) {
|
||||
return getOffset((Point<Euclidean2D>) vector);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public double getOffset(final Point<Euclidean2D> point) {
|
||||
Vector2D p2 = (Vector2D) point;
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Iterator;
|
|||
|
||||
import org.apache.commons.math3.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math3.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
import org.apache.commons.math3.geometry.euclidean.oned.IntervalsSet;
|
||||
import org.apache.commons.math3.geometry.partitioning.Region;
|
||||
import org.apache.commons.math3.geometry.partitioning.RegionFactory;
|
||||
|
@ -90,7 +91,8 @@ class NestedLoops {
|
|||
current = loop[i];
|
||||
final Line line = new Line(previous, current);
|
||||
final IntervalsSet region =
|
||||
new IntervalsSet(line.toSubSpace(previous).getX(), line.toSubSpace(current).getX());
|
||||
new IntervalsSet(line.toSubSpace((Point<Euclidean2D>) previous).getX(),
|
||||
line.toSubSpace((Point<Euclidean2D>) current).getX());
|
||||
edges.add(new SubLine(line, region));
|
||||
}
|
||||
polygon = new PolygonsSet(edges);
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.math3.exception.MathInternalError;
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
import org.apache.commons.math3.geometry.euclidean.oned.Euclidean1D;
|
||||
import org.apache.commons.math3.geometry.euclidean.oned.Interval;
|
||||
import org.apache.commons.math3.geometry.euclidean.oned.IntervalsSet;
|
||||
|
@ -207,7 +208,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
// check if another vertex also happens to be on this line
|
||||
for (final Vertex vertex : vArray) {
|
||||
if (vertex != start && vertex != end &&
|
||||
FastMath.abs(line.getOffset(vertex.getLocation())) <= hyperplaneThickness) {
|
||||
FastMath.abs(line.getOffset((Point<Euclidean2D>) vertex.getLocation())) <= hyperplaneThickness) {
|
||||
vertex.bindWith(line);
|
||||
}
|
||||
}
|
||||
|
@ -268,8 +269,8 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
final List<Edge> minusList = new ArrayList<Edge>();
|
||||
for (final Edge edge : edges) {
|
||||
if (edge != inserted) {
|
||||
final double startOffset = inserted.getLine().getOffset(edge.getStart().getLocation());
|
||||
final double endOffset = inserted.getLine().getOffset(edge.getEnd().getLocation());
|
||||
final double startOffset = inserted.getLine().getOffset((Point<Euclidean2D>) edge.getStart().getLocation());
|
||||
final double endOffset = inserted.getLine().getOffset((Point<Euclidean2D>) edge.getEnd().getLocation());
|
||||
Side startSide = (FastMath.abs(startOffset) <= hyperplaneThickness) ?
|
||||
Side.HYPER : ((startOffset < 0) ? Side.MINUS : Side.PLUS);
|
||||
Side endSide = (FastMath.abs(endOffset) <= hyperplaneThickness) ?
|
||||
|
@ -527,15 +528,15 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
if (tree.getCut() == null && (Boolean) tree.getAttribute()) {
|
||||
// the instance covers the whole space
|
||||
setSize(Double.POSITIVE_INFINITY);
|
||||
setBarycenter(Vector2D.NaN);
|
||||
setBarycenter((Point<Euclidean2D>) Vector2D.NaN);
|
||||
} else {
|
||||
setSize(0);
|
||||
setBarycenter(new Vector2D(0, 0));
|
||||
setBarycenter((Point<Euclidean2D>) new Vector2D(0, 0));
|
||||
}
|
||||
} else if (v[0][0] == null) {
|
||||
// there is at least one open-loop: the polygon is infinite
|
||||
setSize(Double.POSITIVE_INFINITY);
|
||||
setBarycenter(Vector2D.NaN);
|
||||
setBarycenter((Point<Euclidean2D>) Vector2D.NaN);
|
||||
} else {
|
||||
// all loops are closed, we compute some integrals around the shape
|
||||
|
||||
|
@ -561,10 +562,10 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
if (sum < 0) {
|
||||
// the polygon as a finite outside surrounded by an infinite inside
|
||||
setSize(Double.POSITIVE_INFINITY);
|
||||
setBarycenter(Vector2D.NaN);
|
||||
setBarycenter((Point<Euclidean2D>) Vector2D.NaN);
|
||||
} else {
|
||||
setSize(sum / 2);
|
||||
setBarycenter(new Vector2D(sumX / (3 * sum), sumY / (3 * sum)));
|
||||
setBarycenter((Point<Euclidean2D>) new Vector2D(sumX / (3 * sum), sumY / (3 * sum)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -626,8 +627,8 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
final Line line = loop.get(0).getLine();
|
||||
vertices[i++] = new Vector2D[] {
|
||||
null,
|
||||
line.toSpace(new Vector1D(-Float.MAX_VALUE)),
|
||||
line.toSpace(new Vector1D(+Float.MAX_VALUE))
|
||||
line.toSpace((Point<Euclidean1D>) new Vector1D(-Float.MAX_VALUE)),
|
||||
line.toSpace((Point<Euclidean1D>) new Vector1D(+Float.MAX_VALUE))
|
||||
};
|
||||
} else if (loop.get(0).getStart() == null) {
|
||||
// open loop with at least one real point
|
||||
|
@ -637,10 +638,10 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
|
||||
if (j == 0) {
|
||||
// null point and first dummy point
|
||||
double x = segment.getLine().toSubSpace(segment.getEnd()).getX();
|
||||
double x = segment.getLine().toSubSpace((Point<Euclidean2D>) segment.getEnd()).getX();
|
||||
x -= FastMath.max(1.0, FastMath.abs(x / 2));
|
||||
array[j++] = null;
|
||||
array[j++] = segment.getLine().toSpace(new Vector1D(x));
|
||||
array[j++] = segment.getLine().toSpace((Point<Euclidean1D>) new Vector1D(x));
|
||||
}
|
||||
|
||||
if (j < (array.length - 1)) {
|
||||
|
@ -650,9 +651,9 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
|
||||
if (j == (array.length - 1)) {
|
||||
// last dummy point
|
||||
double x = segment.getLine().toSubSpace(segment.getStart()).getX();
|
||||
double x = segment.getLine().toSubSpace((Point<Euclidean2D>) segment.getStart()).getX();
|
||||
x += FastMath.max(1.0, FastMath.abs(x / 2));
|
||||
array[j++] = segment.getLine().toSpace(new Vector1D(x));
|
||||
array[j++] = segment.getLine().toSpace((Point<Euclidean1D>) new Vector1D(x));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -694,7 +695,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
// is this an open or a closed loop ?
|
||||
final boolean open = segment.getStart() == null;
|
||||
|
||||
while ((end != null) && (open || (globalStart.distance(end) > 1.0e-10))) {
|
||||
while ((end != null) && (open || (globalStart.distance((Point<Euclidean2D>) end) > 1.0e-10))) {
|
||||
|
||||
// search the sub-hyperplane starting where the previous one ended
|
||||
AVLTree<ComparableSegment>.Node selectedNode = null;
|
||||
|
@ -706,7 +707,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
(n != null) && (n.getElement().compareTo(upperRight) <= 0);
|
||||
n = n.getNext()) {
|
||||
segment = n.getElement();
|
||||
final double distance = end.distance(segment.getStart());
|
||||
final double distance = end.distance((Point<Euclidean2D>) segment.getStart());
|
||||
if (distance < selectedDistance) {
|
||||
selectedNode = n;
|
||||
selectedSegment = segment;
|
||||
|
@ -842,9 +843,9 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
final List<Interval> intervals = ((IntervalsSet) absSub.getRemainingRegion()).asList();
|
||||
for (final Interval i : intervals) {
|
||||
final Vector2D start = Double.isInfinite(i.getInf()) ?
|
||||
null : (Vector2D) line.toSpace(new Vector1D(i.getInf()));
|
||||
null : (Vector2D) line.toSpace((Point<Euclidean1D>) new Vector1D(i.getInf()));
|
||||
final Vector2D end = Double.isInfinite(i.getSup()) ?
|
||||
null : (Vector2D) line.toSpace(new Vector1D(i.getSup()));
|
||||
null : (Vector2D) line.toSpace((Point<Euclidean1D>) new Vector1D(i.getSup()));
|
||||
if (reversed) {
|
||||
sorted.insert(new ComparableSegment(end, start, line.getReverse()));
|
||||
} else {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.commons.math3.geometry.euclidean.twod;
|
||||
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
|
||||
/** Simple container for a two-points segment.
|
||||
|
@ -95,8 +96,8 @@ public class Segment {
|
|||
|
||||
// if point isn't on the line segment, just return the shortest distance to the end points
|
||||
if (r < 0 || r > 1) {
|
||||
final double dist1 = getStart().distance(p);
|
||||
final double dist2 = getEnd().distance(p);
|
||||
final double dist1 = getStart().distance((Point<Euclidean2D>) p);
|
||||
final double dist2 = getEnd().distance((Point<Euclidean2D>) p);
|
||||
|
||||
return FastMath.min(dist1, dist2);
|
||||
}
|
||||
|
@ -106,7 +107,7 @@ public class Segment {
|
|||
final double py = start.getY() + r * deltaY;
|
||||
|
||||
final Vector2D interPt = new Vector2D(px, py);
|
||||
return interPt.distance(p);
|
||||
return interPt.distance((Point<Euclidean2D>) p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.commons.math3.geometry.euclidean.twod;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
import org.apache.commons.math3.geometry.euclidean.oned.Euclidean1D;
|
||||
import org.apache.commons.math3.geometry.euclidean.oned.Interval;
|
||||
import org.apache.commons.math3.geometry.euclidean.oned.IntervalsSet;
|
||||
|
@ -84,8 +85,8 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
|
|||
final List<Segment> segments = new ArrayList<Segment>(list.size());
|
||||
|
||||
for (final Interval interval : list) {
|
||||
final Vector2D start = line.toSpace(new Vector1D(interval.getInf()));
|
||||
final Vector2D end = line.toSpace(new Vector1D(interval.getSup()));
|
||||
final Vector2D start = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getInf()));
|
||||
final Vector2D end = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getSup()));
|
||||
segments.add(new Segment(start, end, line));
|
||||
}
|
||||
|
||||
|
@ -120,10 +121,10 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
|
|||
}
|
||||
|
||||
// check location of point with respect to first sub-line
|
||||
Location loc1 = getRemainingRegion().checkPoint(line1.toSubSpace(v2D));
|
||||
Location loc1 = getRemainingRegion().checkPoint(line1.toSubSpace((Point<Euclidean2D>) v2D));
|
||||
|
||||
// check location of point with respect to second sub-line
|
||||
Location loc2 = subLine.getRemainingRegion().checkPoint(line2.toSubSpace(v2D));
|
||||
Location loc2 = subLine.getRemainingRegion().checkPoint(line2.toSubSpace((Point<Euclidean2D>) v2D));
|
||||
|
||||
if (includeEndPoints) {
|
||||
return ((loc1 != Location.OUTSIDE) && (loc2 != Location.OUTSIDE)) ? v2D : null;
|
||||
|
@ -140,8 +141,8 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
|
|||
*/
|
||||
private static IntervalsSet buildIntervalSet(final Vector2D start, final Vector2D end) {
|
||||
final Line line = new Line(start, end);
|
||||
return new IntervalsSet(line.toSubSpace(start).getX(),
|
||||
line.toSubSpace(end).getX());
|
||||
return new IntervalsSet(line.toSubSpace((Point<Euclidean2D>) start).getX(),
|
||||
line.toSubSpace((Point<Euclidean2D>) end).getX());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -167,7 +168,7 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
|
|||
|
||||
// the lines do intersect
|
||||
final boolean direct = FastMath.sin(thisLine.getAngle() - otherLine.getAngle()) < 0;
|
||||
final Vector1D x = thisLine.toSubSpace(crossing);
|
||||
final Vector1D x = thisLine.toSubSpace((Point<Euclidean2D>) crossing);
|
||||
return getRemainingRegion().side(new OrientedPoint(x, direct));
|
||||
|
||||
}
|
||||
|
@ -190,7 +191,7 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
|
|||
|
||||
// the lines do intersect
|
||||
final boolean direct = FastMath.sin(thisLine.getAngle() - otherLine.getAngle()) < 0;
|
||||
final Vector1D x = thisLine.toSubSpace(crossing);
|
||||
final Vector1D x = thisLine.toSubSpace((Point<Euclidean2D>) crossing);
|
||||
final SubHyperplane<Euclidean1D> subPlus = new OrientedPoint(x, !direct).wholeHyperplane();
|
||||
final SubHyperplane<Euclidean1D> subMinus = new OrientedPoint(x, direct).wholeHyperplane();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.text.NumberFormat;
|
|||
import org.apache.commons.math3.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math3.exception.MathArithmeticException;
|
||||
import org.apache.commons.math3.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
import org.apache.commons.math3.geometry.Space;
|
||||
import org.apache.commons.math3.geometry.Vector;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
|
@ -292,8 +293,16 @@ public class Vector2D implements Vector<Euclidean2D> {
|
|||
return dx + dy;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.3, replaced with {@link #distance(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
public double distance(Vector<Euclidean2D> p) {
|
||||
return distance((Point<Euclidean2D>) p);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public double distance(Point<Euclidean2D> p) {
|
||||
Vector2D p3 = (Vector2D) p;
|
||||
final double dx = p3.x - x;
|
||||
final double dy = p3.y - y;
|
||||
|
|
|
@ -26,6 +26,8 @@ import java.util.TreeSet;
|
|||
import org.apache.commons.math3.exception.MathInternalError;
|
||||
import org.apache.commons.math3.geometry.Space;
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
import org.apache.commons.math3.geometry.Vector;
|
||||
import org.apache.commons.math3.geometry.partitioning.Region.Location;
|
||||
|
||||
/** Abstract class for all regions, independently of geometry type or dimension.
|
||||
|
||||
|
@ -249,11 +251,35 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
|
|||
return new RegionFactory<S>().difference(region, this).isEmpty();
|
||||
}
|
||||
|
||||
/** Check a point with respect to the region.
|
||||
* @param point point to check
|
||||
* @return a code representing the point status: either {@link
|
||||
* Location#INSIDE}, {@link Location#OUTSIDE} or {@link Location#BOUNDARY}
|
||||
* @deprecated as of 3.3, replaced with {@link #checkPoint(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Location checkPoint(final Vector<S> point) {
|
||||
return checkPoint((Point<S>) point);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Location checkPoint(final Point<S> point) {
|
||||
return checkPoint(tree, point);
|
||||
}
|
||||
|
||||
/** Check a point with respect to the region starting at a given node.
|
||||
* @param node root node of the region
|
||||
* @param point point to check
|
||||
* @return a code representing the point status: either {@link
|
||||
* Region.Location#INSIDE INSIDE}, {@link Region.Location#OUTSIDE
|
||||
* OUTSIDE} or {@link Region.Location#BOUNDARY BOUNDARY}
|
||||
* @deprecated as of 3.3, replaced with {@link #checkPoint(BSPTree, Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
protected Location checkPoint(final BSPTree<S> node, final Vector<S> point) {
|
||||
return checkPoint(node, (Point<S>) point);
|
||||
}
|
||||
|
||||
/** Check a point with respect to the region starting at a given node.
|
||||
* @param node root node of the region
|
||||
* @param point point to check
|
||||
|
@ -430,6 +456,15 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
|
|||
return barycenter;
|
||||
}
|
||||
|
||||
/** Set the barycenter of the instance.
|
||||
* @param barycenter barycenter of the instance
|
||||
* @deprecated as of 3.3, replaced with {@link #setBarycenter(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
protected void setBarycenter(final Vector<S> barycenter) {
|
||||
setBarycenter((Point<S>) barycenter);
|
||||
}
|
||||
|
||||
/** Set the barycenter of the instance.
|
||||
* @param barycenter barycenter of the instance
|
||||
*/
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.List;
|
|||
import org.apache.commons.math3.exception.MathInternalError;
|
||||
import org.apache.commons.math3.geometry.Point;
|
||||
import org.apache.commons.math3.geometry.Space;
|
||||
import org.apache.commons.math3.geometry.Vector;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
|
||||
/** This class represent a Binary Space Partition tree.
|
||||
|
@ -308,7 +309,20 @@ public class BSPTree<S extends Space> {
|
|||
* interior of the node, if the cell is an internal node the points
|
||||
* belongs to the node cut sub-hyperplane.</p>
|
||||
* @param point point to check
|
||||
* @return the tree cell to which the point belongs (can be
|
||||
* @return the tree cell to which the point belongs
|
||||
* @deprecated as of 3.3, replaced with {@link #getCell(Point)}
|
||||
*/
|
||||
@Deprecated
|
||||
public BSPTree<S> getCell(final Vector<S> point) {
|
||||
return getCell((Point<S>) point);
|
||||
}
|
||||
|
||||
/** Get the cell to which a point belongs.
|
||||
* <p>If the returned cell is a leaf node the points belongs to the
|
||||
* interior of the node, if the cell is an internal node the points
|
||||
* belongs to the node cut sub-hyperplane.</p>
|
||||
* @param point point to check
|
||||
* @return the tree cell to which the point belongs
|
||||
*/
|
||||
public BSPTree<S> getCell(final Point<S> point) {
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> {
|
|||
* boundary does not really separate an inside open from an outside
|
||||
* open (open having here its topological meaning), then subsequent
|
||||
* calls to the {@link
|
||||
* org.apache.commons.math3.geometry.partitioning.Region#checkPoint(org.apache.commons.math3.geometry.Vector)
|
||||
* org.apache.commons.math3.geometry.partitioning.Region#checkPoint(org.apache.commons.math3.geometry.Point)
|
||||
* checkPoint} method will not be meaningful anymore.</p>
|
||||
* <p>If the boundary is empty, the region will represent the whole
|
||||
* space.</p>
|
||||
|
|
|
@ -86,6 +86,11 @@ public class S1Point implements Point<Sphere1D> {
|
|||
return Double.isNaN(alpha);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public double distance(final Point<Sphere1D> point) {
|
||||
return distance(this, (S1Point) point);
|
||||
}
|
||||
|
||||
/** Compute the distance (angular separation) between two points.
|
||||
* @param p1 first vector
|
||||
* @param p2 second vector
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.Serializable;
|
|||
import org.apache.commons.math3.exception.MathUnsupportedOperationException;
|
||||
import org.apache.commons.math3.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math3.geometry.Space;
|
||||
import org.apache.commons.math3.geometry.spherical.oned.Sphere1D;
|
||||
|
||||
/**
|
||||
* This class implements a one-dimensional sphere (i.e. a circle).
|
||||
|
|
|
@ -285,7 +285,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
|
|||
* Transform} embedding a 3D rotation.
|
||||
* @param rotation rotation to use
|
||||
* @return a new transform that can be applied to either {@link
|
||||
* Point<Sphere2D> Point<Sphere2D>}, {@link Circle Line} or {@link
|
||||
* Point Point}, {@link Circle Line} or {@link
|
||||
* org.apache.commons.math3.geometry.partitioning.SubHyperplane
|
||||
* SubHyperplane} instances
|
||||
*/
|
||||
|
|
|
@ -169,6 +169,11 @@ public class S2Point implements Point<Sphere2D> {
|
|||
return new S2Point(-theta, FastMath.PI - phi, vector.negate());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public double distance(final Point<Sphere2D> point) {
|
||||
return distance(this, (S2Point) point);
|
||||
}
|
||||
|
||||
/** Compute the distance (angular separation) between two points.
|
||||
* @param p1 first vector
|
||||
* @param p2 second vector
|
||||
|
|
|
@ -104,8 +104,8 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
|
|||
* <p>This constructor does not handle polygons with a boundary
|
||||
* forming several disconnected paths (such as polygons with holes).</p>
|
||||
* <p>For cases where this simple constructor applies, it is expected to
|
||||
* be numerically more robust than the {@link #PolygonsSet(Collection) general
|
||||
* constructor} using {@link SubHyperplane subhyperplanes}.</p>
|
||||
* be numerically more robust than the {@link #SphericalPolygonsSet(Collection,
|
||||
* double) general constructor} using {@link SubHyperplane subhyperplanes}.</p>
|
||||
* <p>If the list is empty, the region will represent the whole
|
||||
* space.</p>
|
||||
* <p>
|
||||
|
@ -804,10 +804,9 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
|
|||
|
||||
// find the edge associated with the selected node
|
||||
for (final Edge edge : edges) {
|
||||
if (edge.getNode() == selected) {
|
||||
if (Vector3D.angle(point.getVector(), edge.getStart().getLocation().getVector()) <= tolerance) {
|
||||
return edge;
|
||||
}
|
||||
if (edge.getNode() == selected &&
|
||||
Vector3D.angle(point.getVector(), edge.getStart().getLocation().getVector()) <= tolerance) {
|
||||
return edge;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue