Java Code Examples for org.apache.commons.math3.geometry.euclidean.threed.Vector3D#crossProduct()
The following examples show how to use
org.apache.commons.math3.geometry.euclidean.threed.Vector3D#crossProduct() .
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: SphericalPolygonsSet.java From astor with GNU General Public License v2.0 | 5 votes |
/** Build the vertices representing a regular polygon. * @param center center of the polygon (the center is in the inside half) * @param meridian point defining the reference meridian for first polygon vertex * @param outsideRadius distance of the vertices to the center * @param n number of sides of the polygon * @return vertices array */ private static S2Point[] createRegularPolygonVertices(final Vector3D center, final Vector3D meridian, final double outsideRadius, final int n) { final S2Point[] array = new S2Point[n]; final Rotation r0 = new Rotation(Vector3D.crossProduct(center, meridian), outsideRadius); array[0] = new S2Point(r0.applyTo(center)); final Rotation r = new Rotation(center, MathUtils.TWO_PI / n); for (int i = 1; i < n; ++i) { array[i] = new S2Point(r.applyTo(array[i - 1].getVector())); } return array; }
Example 2
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testContains() throws MathIllegalArgumentException, MathArithmeticException { Vector3D p1 = new Vector3D(0, 0, 1); Line l = new Line(p1, new Vector3D(0, 0, 2), 1.0e-10); Assert.assertTrue(l.contains(p1)); Assert.assertTrue(l.contains(new Vector3D(1.0, p1, 0.3, l.getDirection()))); Vector3D u = l.getDirection().orthogonal(); Vector3D v = Vector3D.crossProduct(l.getDirection(), u); for (double alpha = 0; alpha < 2 * FastMath.PI; alpha += 0.3) { Assert.assertTrue(! l.contains(p1.add(new Vector3D(FastMath.cos(alpha), u, FastMath.sin(alpha), v)))); } }
Example 3
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testContains() throws MathIllegalArgumentException, MathArithmeticException { Vector3D p1 = new Vector3D(0, 0, 1); Line l = new Line(p1, new Vector3D(0, 0, 2)); Assert.assertTrue(l.contains(p1)); Assert.assertTrue(l.contains(new Vector3D(1.0, p1, 0.3, l.getDirection()))); Vector3D u = l.getDirection().orthogonal(); Vector3D v = Vector3D.crossProduct(l.getDirection(), u); for (double alpha = 0; alpha < 2 * FastMath.PI; alpha += 0.3) { Assert.assertTrue(! l.contains(p1.add(new Vector3D(FastMath.cos(alpha), u, FastMath.sin(alpha), v)))); } }
Example 4
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testContains() { Vector3D p1 = new Vector3D(0, 0, 1); Line l = new Line(p1, new Vector3D(0, 0, 2)); Assert.assertTrue(l.contains(p1)); Assert.assertTrue(l.contains(new Vector3D(1.0, p1, 0.3, l.getDirection()))); Vector3D u = l.getDirection().orthogonal(); Vector3D v = Vector3D.crossProduct(l.getDirection(), u); for (double alpha = 0; alpha < 2 * FastMath.PI; alpha += 0.3) { Assert.assertTrue(! l.contains(p1.add(new Vector3D(FastMath.cos(alpha), u, FastMath.sin(alpha), v)))); } }
Example 5
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testContains() throws MathIllegalArgumentException, MathArithmeticException { Vector3D p1 = new Vector3D(0, 0, 1); Line l = new Line(p1, new Vector3D(0, 0, 2)); Assert.assertTrue(l.contains(p1)); Assert.assertTrue(l.contains(new Vector3D(1.0, p1, 0.3, l.getDirection()))); Vector3D u = l.getDirection().orthogonal(); Vector3D v = Vector3D.crossProduct(l.getDirection(), u); for (double alpha = 0; alpha < 2 * FastMath.PI; alpha += 0.3) { Assert.assertTrue(! l.contains(p1.add(new Vector3D(FastMath.cos(alpha), u, FastMath.sin(alpha), v)))); } }
Example 6
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testContains() { Vector3D p1 = new Vector3D(0, 0, 1); Line l = new Line(p1, new Vector3D(0, 0, 2)); Assert.assertTrue(l.contains(p1)); Assert.assertTrue(l.contains(new Vector3D(1.0, p1, 0.3, l.getDirection()))); Vector3D u = l.getDirection().orthogonal(); Vector3D v = Vector3D.crossProduct(l.getDirection(), u); for (double alpha = 0; alpha < 2 * FastMath.PI; alpha += 0.3) { Assert.assertTrue(! l.contains(p1.add(new Vector3D(FastMath.cos(alpha), u, FastMath.sin(alpha), v)))); } }
Example 7
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testContains() throws MathIllegalArgumentException, MathArithmeticException { Vector3D p1 = new Vector3D(0, 0, 1); Line l = new Line(p1, new Vector3D(0, 0, 2)); Assert.assertTrue(l.contains(p1)); Assert.assertTrue(l.contains(new Vector3D(1.0, p1, 0.3, l.getDirection()))); Vector3D u = l.getDirection().orthogonal(); Vector3D v = Vector3D.crossProduct(l.getDirection(), u); for (double alpha = 0; alpha < 2 * FastMath.PI; alpha += 0.3) { Assert.assertTrue(! l.contains(p1.add(new Vector3D(FastMath.cos(alpha), u, FastMath.sin(alpha), v)))); } }
Example 8
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testContains() throws MathIllegalArgumentException, MathArithmeticException { Vector3D p1 = new Vector3D(0, 0, 1); Line l = new Line(p1, new Vector3D(0, 0, 2)); Assert.assertTrue(l.contains(p1)); Assert.assertTrue(l.contains(new Vector3D(1.0, p1, 0.3, l.getDirection()))); Vector3D u = l.getDirection().orthogonal(); Vector3D v = Vector3D.crossProduct(l.getDirection(), u); for (double alpha = 0; alpha < 2 * FastMath.PI; alpha += 0.3) { Assert.assertTrue(! l.contains(p1.add(new Vector3D(FastMath.cos(alpha), u, FastMath.sin(alpha), v)))); } }
Example 9
Source File: SphericalPolygonsSet.java From astor with GNU General Public License v2.0 | 5 votes |
/** Build the vertices representing a regular polygon. * @param center center of the polygon (the center is in the inside half) * @param meridian point defining the reference meridian for first polygon vertex * @param outsideRadius distance of the vertices to the center * @param n number of sides of the polygon * @return vertices array */ private static S2Point[] createRegularPolygonVertices(final Vector3D center, final Vector3D meridian, final double outsideRadius, final int n) { final S2Point[] array = new S2Point[n]; final Rotation r0 = new Rotation(Vector3D.crossProduct(center, meridian), outsideRadius); array[0] = new S2Point(r0.applyTo(center)); final Rotation r = new Rotation(center, MathUtils.TWO_PI / n); for (int i = 1; i < n; ++i) { array[i] = new S2Point(r.applyTo(array[i - 1].getVector())); } return array; }
Example 10
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testContains() throws MathIllegalArgumentException, MathArithmeticException { Vector3D p1 = new Vector3D(0, 0, 1); Line l = new Line(p1, new Vector3D(0, 0, 2), 1.0e-10); Assert.assertTrue(l.contains(p1)); Assert.assertTrue(l.contains(new Vector3D(1.0, p1, 0.3, l.getDirection()))); Vector3D u = l.getDirection().orthogonal(); Vector3D v = Vector3D.crossProduct(l.getDirection(), u); for (double alpha = 0; alpha < 2 * FastMath.PI; alpha += 0.3) { Assert.assertTrue(! l.contains(p1.add(new Vector3D(FastMath.cos(alpha), u, FastMath.sin(alpha), v)))); } }
Example 11
Source File: GeoPoint.java From log-synth with Apache License 2.0 | 5 votes |
public Vector3D east(Vector3D r) { Vector3D ux = r.crossProduct(Z); if (ux.getNorm() < 1e-4) { // near the poles (i.e. < 640 meters from them), the definition of east is difficult ux = this.r.crossProduct(X); } ux = ux.normalize(); return ux; }