Java Code Examples for org.apache.commons.math3.geometry.euclidean.threed.Vector3D#angle()
The following examples show how to use
org.apache.commons.math3.geometry.euclidean.threed.Vector3D#angle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SubCircle.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ @Override public Side side(final Hyperplane<Sphere2D> hyperplane) { final Circle thisCircle = (Circle) getHyperplane(); final Circle otherCircle = (Circle) hyperplane; final double angle = Vector3D.angle(thisCircle.getPole(), otherCircle.getPole()); if (angle < thisCircle.getTolerance() || angle > FastMath.PI - thisCircle.getTolerance()) { // the two circles are aligned or opposite return Side.HYPER; } else { // the two circles intersect each other return ((ArcsSet) getRemainingRegion()).side(thisCircle.getInsideArc(otherCircle)); } }
Example 2
Source File: SubCircle.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ @Override public Side side(final Hyperplane<Sphere2D> hyperplane) { final Circle thisCircle = (Circle) getHyperplane(); final Circle otherCircle = (Circle) hyperplane; final double angle = Vector3D.angle(thisCircle.getPole(), otherCircle.getPole()); if (angle < thisCircle.getTolerance() || angle > FastMath.PI - thisCircle.getTolerance()) { // the two circles are aligned or opposite return Side.HYPER; } else { // the two circles intersect each other return ((ArcsSet) getRemainingRegion()).side(thisCircle.getInsideArc(otherCircle)); } }
Example 3
Source File: EdgesBuilder.java From astor with GNU General Public License v2.0 | 5 votes |
/** Get the edge that should naturally follow another one. * @param previous edge to be continued * @return other edge, starting where the previous one ends (they * have not been connected yet) * @exception MathIllegalStateException if there is not a single other edge */ private Edge getFollowingEdge(final Edge previous) throws MathIllegalStateException { // get the candidate nodes final S2Point point = previous.getEnd().getLocation(); final List<BSPTree<Sphere2D>> candidates = root.getCloseCuts(point, tolerance); // the following edge we are looking for must start from one of the candidates nodes double closest = tolerance; Edge following = null; for (final BSPTree<Sphere2D> node : candidates) { for (final Edge edge : nodeToEdgesList.get(node)) { if (edge != previous && edge.getStart().getIncoming() == null) { final Vector3D edgeStart = edge.getStart().getLocation().getVector(); final double gap = Vector3D.angle(point.getVector(), edgeStart); if (gap <= closest) { closest = gap; following = edge; } } } } if (following == null) { final Vector3D previousStart = previous.getStart().getLocation().getVector(); if (Vector3D.angle(point.getVector(), previousStart) <= tolerance) { // the edge connects back to itself return previous; } // this should never happen throw new MathIllegalStateException(LocalizedFormats.OUTLINE_BOUNDARY_LOOP_OPEN); } return following; }
Example 4
Source File: EdgesBuilder.java From astor with GNU General Public License v2.0 | 5 votes |
/** Get the edge that should naturally follow another one. * @param previous edge to be continued * @return other edge, starting where the previous one ends (they * have not been connected yet) * @exception MathIllegalStateException if there is not a single other edge */ private Edge getFollowingEdge(final Edge previous) throws MathIllegalStateException { // get the candidate nodes final S2Point point = previous.getEnd().getLocation(); final List<BSPTree<Sphere2D>> candidates = root.getCloseCuts(point, tolerance); // the following edge we are looking for must start from one of the candidates nodes double closest = tolerance; Edge following = null; for (final BSPTree<Sphere2D> node : candidates) { for (final Edge edge : nodeToEdgesList.get(node)) { if (edge != previous && edge.getStart().getIncoming() == null) { final Vector3D edgeStart = edge.getStart().getLocation().getVector(); final double gap = Vector3D.angle(point.getVector(), edgeStart); if (gap <= closest) { closest = gap; following = edge; } } } } if (following == null) { final Vector3D previousStart = previous.getStart().getLocation().getVector(); if (Vector3D.angle(point.getVector(), previousStart) <= tolerance) { // the edge connects back to itself return previous; } // this should never happen throw new MathIllegalStateException(LocalizedFormats.OUTLINE_BOUNDARY_LOOP_OPEN); } return following; }
Example 5
Source File: Circle.java From astor with GNU General Public License v2.0 | 2 votes |
/** Get the offset (oriented distance) of a direction. * <p>The offset is defined as the angular distance between the * circle center and the direction minus the circle radius. It * is therefore 0 on the circle, positive for directions outside of * the cone delimited by the circle, and negative inside the cone.</p> * @param direction direction to check * @return offset of the direction * @see #getOffset(Point) */ public double getOffset(final Vector3D direction) { return Vector3D.angle(pole, direction) - 0.5 * FastMath.PI; }
Example 6
Source File: S2Point.java From astor with GNU General Public License v2.0 | 2 votes |
/** Simple constructor. * Build a vector from its underlying 3D vector * @param vector 3D vector * @exception MathArithmeticException if vector norm is zero */ public S2Point(final Vector3D vector) throws MathArithmeticException { this(FastMath.atan2(vector.getY(), vector.getX()), Vector3D.angle(Vector3D.PLUS_K, vector), vector.normalize()); }
Example 7
Source File: S2Point.java From astor with GNU General Public License v2.0 | 2 votes |
/** Compute the distance (angular separation) between two points. * @param p1 first vector * @param p2 second vector * @return the angular separation between p1 and p2 */ public static double distance(S2Point p1, S2Point p2) { return Vector3D.angle(p1.vector, p2.vector); }
Example 8
Source File: Circle.java From astor with GNU General Public License v2.0 | 2 votes |
/** Get the offset (oriented distance) of a direction. * <p>The offset is defined as the angular distance between the * circle center and the direction minus the circle radius. It * is therefore 0 on the circle, positive for directions outside of * the cone delimited by the circle, and negative inside the cone.</p> * @param direction direction to check * @return offset of the direction * @see #getOffset(Point) */ public double getOffset(final Vector3D direction) { return Vector3D.angle(pole, direction) - 0.5 * FastMath.PI; }
Example 9
Source File: S2Point.java From astor with GNU General Public License v2.0 | 2 votes |
/** Simple constructor. * Build a vector from its underlying 3D vector * @param vector 3D vector * @exception MathArithmeticException if vector norm is zero */ public S2Point(final Vector3D vector) throws MathArithmeticException { this(FastMath.atan2(vector.getY(), vector.getX()), Vector3D.angle(Vector3D.PLUS_K, vector), vector.normalize()); }
Example 10
Source File: S2Point.java From astor with GNU General Public License v2.0 | 2 votes |
/** Compute the distance (angular separation) between two points. * @param p1 first vector * @param p2 second vector * @return the angular separation between p1 and p2 */ public static double distance(S2Point p1, S2Point p2) { return Vector3D.angle(p1.vector, p2.vector); }