org.apache.commons.math3.geometry.euclidean.twod.Euclidean2D Java Examples
The following examples show how to use
org.apache.commons.math3.geometry.euclidean.twod.Euclidean2D.
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: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; final Vector2D shift = tPlane.toSubSpace(apply(oPlane.getOrigin())); final AffineTransform at = AffineTransform.getTranslateInstance(shift.getX(), shift.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #2
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** Add he contribution of a boundary facet. * @param facet boundary facet * @param reversed if true, the facet has the inside on its plus side */ private void addContribution(final SubHyperplane<Euclidean3D> facet, final boolean reversed) { final Region<Euclidean2D> polygon = ((SubPlane) facet).getRemainingRegion(); final double area = polygon.getSize(); if (Double.isInfinite(area)) { setSize(Double.POSITIVE_INFINITY); setBarycenter(Vector3D.NaN); } else { final Plane plane = (Plane) facet.getHyperplane(); final Vector3D facetB = plane.toSpace(polygon.getBarycenter()); double scaled = area * facetB.dotProduct(plane.getNormal()); if (reversed) { scaled = -scaled; } setSize(getSize() + scaled); setBarycenter(new Vector3D(1.0, (Vector3D) getBarycenter(), scaled, facetB)); } }
Example #3
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** Add he contribution of a boundary facet. * @param facet boundary facet * @param reversed if true, the facet has the inside on its plus side */ private void addContribution(final SubHyperplane<Euclidean3D> facet, final boolean reversed) { final Region<Euclidean2D> polygon = ((SubPlane) facet).getRemainingRegion(); final double area = polygon.getSize(); if (Double.isInfinite(area)) { setSize(Double.POSITIVE_INFINITY); setBarycenter(Vector3D.NaN); } else { final Plane plane = (Plane) facet.getHyperplane(); final Vector3D facetB = plane.toSpace(polygon.getBarycenter()); double scaled = area * facetB.dotProduct(plane.getNormal()); if (reversed) { scaled = -scaled; } setSize(getSize() + scaled); setBarycenter(new Vector3D(1.0, (Vector3D) getBarycenter(), scaled, facetB)); } }
Example #4
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; final Vector2D shift = tPlane.toSubSpace(apply(oPlane.getOrigin())); final AffineTransform at = AffineTransform.getTranslateInstance(shift.getX(), shift.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #5
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform 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 AffineTransform at = new AffineTransform(tP10.getX() - tP00.getX(), tP10.getY() - tP00.getY(), tP01.getX() - tP00.getX(), tP01.getY() - tP00.getY(), tP00.getX(), tP00.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #6
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; final Vector2D shift = tPlane.toSubSpace(apply(oPlane.getOrigin())); final AffineTransform at = AffineTransform.getTranslateInstance(shift.getX(), shift.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #7
Source File: EnclosingDiskEvaluator.java From lucene-solr with Apache License 2.0 | 6 votes |
@SuppressWarnings({"rawtypes"}) public static EnclosingBall getEnclosingDisk(Matrix matrix) throws IOException { double[][] data = matrix.getData(); List<Vector2D> points = new ArrayList<>(data.length); if(data[0].length == 2) { for(double[] row : data) { points.add(new Vector2D(row[0], row[1])); } @SuppressWarnings({"unchecked"}) WelzlEncloser<Euclidean2D, Vector2D> welzlEncloser = new WelzlEncloser(.001, new DiskGenerator()); EnclosingBall enclosingBall = welzlEncloser.enclose(points); return enclosingBall; } else { throw new IOException("The enclosingDisk function operates on a matrix of 2D vectors"); } }
Example #8
Source File: NPEfix10_ten_s.java From coming with MIT License | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; final Vector2D shift = tPlane.toSubSpace((Point<Euclidean3D>) apply(oPlane.getOrigin())); final AffineTransform at = AffineTransform.getTranslateInstance(shift.getX(), shift.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #9
Source File: NPEfix10_ten_s.java From coming with MIT License | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; final Vector3D p00 = oPlane.getOrigin(); 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(), tP00.getX(), tP00.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #10
Source File: NPEfix10_ten_s.java From coming with MIT License | 6 votes |
/** Add he contribution of a boundary facet. * @param facet boundary facet * @param reversed if true, the facet has the inside on its plus side */ private void addContribution(final SubHyperplane<Euclidean3D> facet, final boolean reversed) { final Region<Euclidean2D> polygon = ((SubPlane) facet).getRemainingRegion(); final double area = polygon.getSize(); if (Double.isInfinite(area)) { setSize(Double.POSITIVE_INFINITY); setBarycenter((Point<Euclidean3D>) Vector3D.NaN); } else { final Plane plane = (Plane) facet.getHyperplane(); final Vector3D facetB = plane.toSpace(polygon.getBarycenter()); double scaled = area * facetB.dotProduct(plane.getNormal()); if (reversed) { scaled = -scaled; } setSize(getSize() + scaled); setBarycenter((Point<Euclidean3D>) new Vector3D(1.0, (Vector3D) getBarycenter(), scaled, facetB)); } }
Example #11
Source File: NPEfix10_ten_t.java From coming with MIT License | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; final Vector3D p00 = oPlane.getOrigin(); 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(), tP00.getX(), tP00.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #12
Source File: NPEfix10_ten_t.java From coming with MIT License | 6 votes |
/** Add he contribution of a boundary facet. * @param facet boundary facet * @param reversed if true, the facet has the inside on its plus side */ private void addContribution(final SubHyperplane<Euclidean3D> facet, final boolean reversed) { final Region<Euclidean2D> polygon = ((SubPlane) facet).getRemainingRegion(); final double area = polygon.getSize(); if (Double.isInfinite(area)) { setSize(Double.POSITIVE_INFINITY); setBarycenter((Point<Euclidean3D>) Vector3D.NaN); } else { final Plane plane = (Plane) facet.getHyperplane(); final Vector3D facetB = plane.toSpace(polygon.getBarycenter()); double scaled = area * facetB.dotProduct(plane.getNormal()); if (reversed) { scaled = -scaled; } setSize(getSize() + scaled); setBarycenter((Point<Euclidean3D>) new Vector3D(1.0, (Vector3D) getBarycenter(), scaled, facetB)); } }
Example #13
Source File: ConvexHullGenerator2DAbstractTest.java From astor with GNU General Public License v2.0 | 6 votes |
protected final void checkPointsInsideHullRegion(final Collection<Vector2D> points, final ConvexHull2D hull, final boolean includesCollinearPoints) { final Collection<Vector2D> hullVertices = Arrays.asList(hull.getVertices()); final Region<Euclidean2D> region = hull.createRegion(); for (final Vector2D p : points) { Location location = region.checkPoint(p); Assert.assertTrue(location != Location.OUTSIDE); if (location == Location.BOUNDARY && includesCollinearPoints) { Assert.assertTrue(hullVertices.contains(p)); } } }
Example #14
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** Add he contribution of a boundary facet. * @param facet boundary facet * @param reversed if true, the facet has the inside on its plus side */ private void addContribution(final SubHyperplane<Euclidean3D> facet, final boolean reversed) { final Region<Euclidean2D> polygon = ((SubPlane) facet).getRemainingRegion(); final double area = polygon.getSize(); if (Double.isInfinite(area)) { setSize(Double.POSITIVE_INFINITY); setBarycenter((Point<Euclidean3D>) Vector3D.NaN); } else { final Plane plane = (Plane) facet.getHyperplane(); final Vector3D facetB = plane.toSpace(polygon.getBarycenter()); double scaled = area * facetB.dotProduct(plane.getNormal()); if (reversed) { scaled = -scaled; } setSize(getSize() + scaled); setBarycenter((Point<Euclidean3D>) new Vector3D(1.0, (Vector3D) getBarycenter(), scaled, facetB)); } }
Example #15
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; final Vector3D p00 = oPlane.getOrigin(); 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(), tP00.getX(), tP00.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #16
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; final Vector2D shift = tPlane.toSubSpace((Point<Euclidean3D>) apply(oPlane.getOrigin())); final AffineTransform at = AffineTransform.getTranslateInstance(shift.getX(), shift.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #17
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; final Vector2D shift = tPlane.toSubSpace((Point<Euclidean3D>) apply(oPlane.getOrigin())); final AffineTransform at = AffineTransform.getTranslateInstance(shift.getX(), shift.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #18
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** Add he contribution of a boundary facet. * @param facet boundary facet * @param reversed if true, the facet has the inside on its plus side */ private void addContribution(final SubHyperplane<Euclidean3D> facet, final boolean reversed) { final Region<Euclidean2D> polygon = ((SubPlane) facet).getRemainingRegion(); final double area = polygon.getSize(); if (Double.isInfinite(area)) { setSize(Double.POSITIVE_INFINITY); setBarycenter(Vector3D.NaN); } else { final Plane plane = (Plane) facet.getHyperplane(); final Vector3D facetB = plane.toSpace(polygon.getBarycenter()); double scaled = area * facetB.dotProduct(plane.getNormal()); if (reversed) { scaled = -scaled; } setSize(getSize() + scaled); setBarycenter(new Vector3D(1.0, (Vector3D) getBarycenter(), scaled, facetB)); } }
Example #19
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; final Vector2D shift = tPlane.toSubSpace(apply(oPlane.getOrigin())); final AffineTransform at = AffineTransform.getTranslateInstance(shift.getX(), shift.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #20
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform 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 AffineTransform at = new AffineTransform(tP10.getX() - tP00.getX(), tP10.getY() - tP00.getY(), tP01.getX() - tP00.getX(), tP01.getY() - tP00.getY(), tP00.getX(), tP00.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #21
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform 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 AffineTransform at = new AffineTransform(tP10.getX() - tP00.getX(), tP10.getY() - tP00.getY(), tP01.getX() - tP00.getX(), tP01.getY() - tP00.getY(), tP00.getX(), tP00.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #22
Source File: ConvexHullGenerator2DAbstractTest.java From astor with GNU General Public License v2.0 | 6 votes |
protected final void checkPointsInsideHullRegion(final Collection<Vector2D> points, final ConvexHull2D hull, final boolean includesCollinearPoints) { final Collection<Vector2D> hullVertices = Arrays.asList(hull.getVertices()); final Region<Euclidean2D> region = hull.createRegion(); for (final Vector2D p : points) { Location location = region.checkPoint(p); Assert.assertTrue(location != Location.OUTSIDE); if (location == Location.BOUNDARY && includesCollinearPoints) { Assert.assertTrue(hullVertices.contains(p)); } } }
Example #23
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; final Vector3D p00 = oPlane.getOrigin(); 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(), tP00.getX(), tP00.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #24
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; final Vector2D shift = tPlane.toSubSpace(apply(oPlane.getOrigin())); final AffineTransform at = AffineTransform.getTranslateInstance(shift.getX(), shift.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #25
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** Add he contribution of a boundary facet. * @param facet boundary facet * @param reversed if true, the facet has the inside on its plus side */ private void addContribution(final SubHyperplane<Euclidean3D> facet, final boolean reversed) { final Region<Euclidean2D> polygon = ((SubPlane) facet).getRemainingRegion(); final double area = polygon.getSize(); if (Double.isInfinite(area)) { setSize(Double.POSITIVE_INFINITY); setBarycenter((Point<Euclidean3D>) Vector3D.NaN); } else { final Plane plane = (Plane) facet.getHyperplane(); final Vector3D facetB = plane.toSpace(polygon.getBarycenter()); double scaled = area * facetB.dotProduct(plane.getNormal()); if (reversed) { scaled = -scaled; } setSize(getSize() + scaled); setBarycenter((Point<Euclidean3D>) new Vector3D(1.0, (Vector3D) getBarycenter(), scaled, facetB)); } }
Example #26
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** Add he contribution of a boundary facet. * @param facet boundary facet * @param reversed if true, the facet has the inside on its plus side */ private void addContribution(final SubHyperplane<Euclidean3D> facet, final boolean reversed) { final Region<Euclidean2D> polygon = ((SubPlane) facet).getRemainingRegion(); final double area = polygon.getSize(); if (Double.isInfinite(area)) { setSize(Double.POSITIVE_INFINITY); setBarycenter(Vector3D.NaN); } else { final Plane plane = (Plane) facet.getHyperplane(); final Vector3D facetB = plane.toSpace(polygon.getBarycenter()); double scaled = area * facetB.dotProduct(plane.getNormal()); if (reversed) { scaled = -scaled; } setSize(getSize() + scaled); setBarycenter(new Vector3D(1.0, (Vector3D) getBarycenter(), scaled, facetB)); } }
Example #27
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform 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 AffineTransform at = new AffineTransform(tP10.getX() - tP00.getX(), tP10.getY() - tP00.getY(), tP01.getX() - tP00.getX(), tP01.getY() - tP00.getY(), tP00.getX(), tP00.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #28
Source File: PolyhedronsSet.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> transformed) { if (original != cachedOriginal) { // we have changed hyperplane, reset the in-hyperplane transform 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 AffineTransform at = new AffineTransform(tP10.getX() - tP00.getX(), tP10.getY() - tP00.getY(), tP01.getX() - tP00.getX(), tP01.getY() - tP00.getY(), tP00.getX(), tP00.getY()); cachedOriginal = (Plane) original; cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at); } return ((SubLine) sub).applyTransform(cachedTransform); }
Example #29
Source File: WelzlEncloser2DTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testNoPoints() { DiskGenerator generator = new DiskGenerator(); WelzlEncloser<Euclidean2D, Vector2D> encloser = new WelzlEncloser<Euclidean2D, Vector2D>(1.0e-10, generator); EnclosingBall<Euclidean2D, Vector2D> ball = encloser.enclose(new ArrayList<Vector2D>()); Assert.assertTrue(ball.getRadius() < 0); }
Example #30
Source File: ConvexHull2D.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ public Region<Euclidean2D> createRegion() throws InsufficientDataException { if (vertices.length < 3) { throw new InsufficientDataException(); } final RegionFactory<Euclidean2D> factory = new RegionFactory<Euclidean2D>(); final Segment[] segments = retrieveLineSegments(); final Line[] lineArray = new Line[segments.length]; for (int i = 0; i < segments.length; i++) { lineArray[i] = segments[i].getLine(); } return factory.buildConvex(lineArray); }