List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D ZERO
Vector3D ZERO
To view the source code for org.apache.commons.math3.geometry.euclidean.threed Vector3D ZERO.
Click Source Link
From source file:org.jtrfp.trcl.TriangleList.java
public Vector3D getMaximumVertexDims() { if (isPrimitivesFinalized()) return cachedMaximumVertexDims; Vector3D result = Vector3D.ZERO; Triangle[][] t = getPrimitives();/*from w ww . j a v a2 s. c o m*/ for (Triangle[] frame : t) { for (Triangle tri : frame) { for (int i = 0; i < 3; i++) { double v; final Vector3D pos = tri.getVertices()[i].getPosition(); v = pos.getX(); result = result.getX() < v ? new Vector3D(v, result.getY(), result.getZ()) : result; v = pos.getY(); result = result.getY() < v ? new Vector3D(result.getX(), v, result.getZ()) : result; v = pos.getZ(); result = result.getZ() < v ? new Vector3D(result.getX(), result.getY(), v) : result; } // end for(vertex) } // end for(triangle) } // end for(triangles) return result; }
From source file:org.jtrfp.trcl.Tunnel.java
private Vector3D buildTunnel(TDFFile.Tunnel _tun, Vector3D groundVector, boolean entrance) throws IllegalAccessException, UnrecognizedFormatException, FileNotFoundException, FileLoadException, IOException {/*w ww . jav a2s.co m*/ // Entrance uses only a stub. Player is warped to TUNNEL_POS facing // TUNNEL_START_DIRECTION ResourceManager rm = tr.getResourceManager(); LVLFile tlvl = rm.getLVL(_tun.getTunnelLVLFile()); final ColorPaletteVectorList tunnelColorPalette = new ColorPaletteVectorList( tr.getResourceManager().getPalette(lvl.getGlobalPaletteFile())); TextureDescription[] tunnelTexturePalette = rm.getTextures(tlvl.getLevelTextureListFile(), paletteVL, ESTuTvPalette, true); TNLFile tun = tr.getResourceManager().getTNLData(tlvl.getHeightMapOrTunnelFile()); final double segLen = 65536; final double bendiness = 18; List<Segment> segs = tun.getSegments(); final LoadingProgressReporter[] reporters = tunnelAssemblyReporter.generateSubReporters(segs.size()); // Vector3D tunnelEnd = TUNNEL_START_POS; Rotation rotation = entrance ? new Rotation(new Vector3D(0, 0, 1), groundVector) : new Rotation(new Vector3D(0, 0, 1), new Vector3D(1, 0, 0)); Vector3D startPoint = TUNNEL_START_POS; Vector3D segPos = Vector3D.ZERO; final Vector3D top = rotation.applyTo(new Vector3D(0, 1, 0)); /* if (entrance) { // Entrance is just a stub so we only need a few of the segments List<Segment> newSegs = new ArrayList<Segment>(); for (int i = 0; i < 10; i++) { newSegs.add(segs.get(i)); } segs = newSegs; }*/ // CONSTRUCT AND INSTALL SEGMENTS int segIndex = 0; Vector3D finalPos = TUNNEL_START_POS; for (Segment s : segs) { reporters[segIndex].complete(); tr.getReporter().report( "org.jtrfp.trcl.Tunnel." + _tun.getTunnelLVLFile() + ".segment" + (segIndex++) + "", s.getObstacle().name()); // Figure out the space the segment will take Vector3D positionDelta = new Vector3D((double) (s.getEndX() - s.getStartX()) * bendiness * -1, (double) (s.getEndY() - s.getStartY()) * bendiness, segLen); // Create the segment Vector3D position = startPoint.add(rotation.applyTo(segPos)); TunnelSegment ts = new TunnelSegment(tr, s, tunnelTexturePalette, segLen, positionDelta.getX(), positionDelta.getY()); ts.setPosition(position.toArray()); ts.setHeading(entrance ? groundVector : Vector3D.PLUS_I); ts.setTop(entrance ? top : Vector3D.PLUS_J); // Install the segment add(ts); installObstacles(s, tunnelColorPalette, ESTuTvPalette, tunnelTexturePalette, entrance ? groundVector : Vector3D.PLUS_I, entrance ? top : Vector3D.PLUS_J, position, TR.legacy2Modern(s.getStartWidth() * TunnelSegment.TUNNEL_DIA_SCALAR), TR.legacy2Modern(s.getStartWidth() * TunnelSegment.TUNNEL_DIA_SCALAR), tr); // Move origin to next segment segPos = segPos.add(positionDelta); finalPos = position; } // end for(segments) return finalPos; }
From source file:org.orekit.attitudes.AttitudesSequenceTest.java
@Test public void testDayNightSwitch() throws OrekitException { // Initial state definition : date, orbit final AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC()); final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680); final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231); final Orbit initialOrbit = new KeplerianOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initialDate, Constants.EIGEN5C_EARTH_MU); final//from w ww. j av a2 s . com // Attitudes sequence definition EventsLogger logger = new EventsLogger(); final AttitudesSequence attitudesSequence = new AttitudesSequence(); final AttitudeProvider dayObservationLaw = new LofOffset(initialOrbit.getFrame(), LOFType.VVLH, RotationOrder.XYZ, FastMath.toRadians(20), FastMath.toRadians(40), 0); final AttitudeProvider nightRestingLaw = new LofOffset(initialOrbit.getFrame(), LOFType.VVLH); final PVCoordinatesProvider sun = CelestialBodyFactory.getSun(); final PVCoordinatesProvider earth = CelestialBodyFactory.getEarth(); final EclipseDetector ed = new EclipseDetector(sun, 696000000., earth, Constants.WGS84_EARTH_EQUATORIAL_RADIUS).withHandler(new ContinueOnEvent<EclipseDetector>() { public EventHandler.Action eventOccurred(final SpacecraftState s, final EclipseDetector d, final boolean increasing) { setInEclipse(s.getDate(), !increasing); return EventHandler.Action.CONTINUE; } }); final EventDetector monitored = logger.monitorDetector(ed); final Handler dayToNightHandler = new Handler(dayObservationLaw, nightRestingLaw); final Handler nightToDayHandler = new Handler(nightRestingLaw, dayObservationLaw); attitudesSequence.addSwitchingCondition(dayObservationLaw, nightRestingLaw, monitored, false, true, 300.0, AngularDerivativesFilter.USE_RRA, dayToNightHandler); attitudesSequence.addSwitchingCondition(nightRestingLaw, dayObservationLaw, monitored, true, false, 300.0, AngularDerivativesFilter.USE_RRA, nightToDayHandler); if (ed.g(new SpacecraftState(initialOrbit)) >= 0) { // initial position is in daytime setInEclipse(initialDate, false); attitudesSequence.resetActiveProvider(dayObservationLaw); } else { // initial position is in nighttime setInEclipse(initialDate, true); attitudesSequence.resetActiveProvider(nightRestingLaw); } // Propagator : consider the analytical Eckstein-Hechler model final Propagator propagator = new EcksteinHechlerPropagator(initialOrbit, attitudesSequence, Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20, Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40, Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60); // Register the switching events to the propagator attitudesSequence.registerSwitchEvents(propagator); propagator.setMasterMode(60.0, new OrekitFixedStepHandler() { public void init(final SpacecraftState s0, final AbsoluteDate t) { } public void handleStep(SpacecraftState currentState, boolean isLast) throws PropagationException { try { // the Earth position in spacecraft frame should be along spacecraft Z axis // during night time and away from it during day time due to roll and pitch offsets final Vector3D earth = currentState.toTransform().transformPosition(Vector3D.ZERO); final double pointingOffset = Vector3D.angle(earth, Vector3D.PLUS_K); // the g function is the eclipse indicator, its an angle between Sun and Earth limb, // positive when Sun is outside of Earth limb, negative when Sun is hidden by Earth limb final double eclipseAngle = ed.g(currentState); if (currentState.getDate().durationFrom(lastChange) > 300) { if (inEclipse) { Assert.assertTrue(eclipseAngle <= 0); Assert.assertEquals(0.0, pointingOffset, 1.0e-6); } else { Assert.assertTrue(eclipseAngle >= 0); Assert.assertEquals(0.767215, pointingOffset, 1.0e-6); } } else { // we are in transition Assert.assertTrue(pointingOffset + " " + (0.767215 - pointingOffset), pointingOffset <= 0.7672155); } } catch (OrekitException oe) { throw new PropagationException(oe); } } }); // Propagate from the initial date for the fixed duration propagator.propagate(initialDate.shiftedBy(12600.)); // as we have 2 switch events (even if they share the same underlying event detector), // and these events are triggered at both eclipse entry and exit, we get 8 // raw events on 2 orbits Assert.assertEquals(8, logger.getLoggedEvents().size()); // we have 4 attitudes switch on 2 orbits, 2 of each type Assert.assertEquals(2, dayToNightHandler.dates.size()); Assert.assertEquals(2, nightToDayHandler.dates.size()); }
From source file:org.orekit.attitudes.AttitudeTest.java
@Test public void testZeroRate() throws OrekitException { Attitude attitude = new Attitude(AbsoluteDate.J2000_EPOCH, FramesFactory.getEME2000(), new Rotation(0.48, 0.64, 0.36, 0.48, false), Vector3D.ZERO, Vector3D.ZERO); Assert.assertEquals(Vector3D.ZERO, attitude.getSpin()); double dt = 10.0; Attitude shifted = attitude.shiftedBy(dt); Assert.assertEquals(Vector3D.ZERO, shifted.getRotationAcceleration()); Assert.assertEquals(Vector3D.ZERO, shifted.getSpin()); Assert.assertEquals(0.0, Rotation.distance(attitude.getRotation(), shifted.getRotation()), 1.0e-15); }
From source file:org.orekit.attitudes.AttitudeTest.java
@Test public void testShift() throws OrekitException { double rate = 2 * FastMath.PI / (12 * 60); Attitude attitude = new Attitude(AbsoluteDate.J2000_EPOCH, FramesFactory.getEME2000(), Rotation.IDENTITY, new Vector3D(rate, Vector3D.PLUS_K), Vector3D.ZERO); Assert.assertEquals(rate, attitude.getSpin().getNorm(), 1.0e-10); double dt = 10.0; double alpha = rate * dt; Attitude shifted = attitude.shiftedBy(dt); Assert.assertEquals(rate, shifted.getSpin().getNorm(), 1.0e-10); Assert.assertEquals(alpha, Rotation.distance(attitude.getRotation(), shifted.getRotation()), 1.0e-10); Vector3D xSat = shifted.getRotation().applyInverseTo(Vector3D.PLUS_I); Assert.assertEquals(0.0, xSat.subtract(new Vector3D(FastMath.cos(alpha), FastMath.sin(alpha), 0)).getNorm(), 1.0e-10);/*from w w w . j a v a 2 s . c o m*/ Vector3D ySat = shifted.getRotation().applyInverseTo(Vector3D.PLUS_J); Assert.assertEquals(0.0, ySat.subtract(new Vector3D(-FastMath.sin(alpha), FastMath.cos(alpha), 0)).getNorm(), 1.0e-10); Vector3D zSat = shifted.getRotation().applyInverseTo(Vector3D.PLUS_K); Assert.assertEquals(0.0, zSat.subtract(Vector3D.PLUS_K).getNorm(), 1.0e-10); }
From source file:org.orekit.attitudes.AttitudeTest.java
@Test public void testSpin() throws OrekitException { double rate = 2 * FastMath.PI / (12 * 60); Attitude attitude = new Attitude(AbsoluteDate.J2000_EPOCH, FramesFactory.getEME2000(), new Rotation(0.48, 0.64, 0.36, 0.48, false), new Vector3D(rate, Vector3D.PLUS_K), Vector3D.ZERO); Assert.assertEquals(rate, attitude.getSpin().getNorm(), 1.0e-10); double dt = 10.0; Attitude shifted = attitude.shiftedBy(dt); Assert.assertEquals(rate, shifted.getSpin().getNorm(), 1.0e-10); Assert.assertEquals(rate * dt, Rotation.distance(attitude.getRotation(), shifted.getRotation()), 1.0e-10); Vector3D shiftedX = shifted.getRotation().applyInverseTo(Vector3D.PLUS_I); Vector3D shiftedY = shifted.getRotation().applyInverseTo(Vector3D.PLUS_J); Vector3D shiftedZ = shifted.getRotation().applyInverseTo(Vector3D.PLUS_K); Vector3D originalX = attitude.getRotation().applyInverseTo(Vector3D.PLUS_I); Vector3D originalY = attitude.getRotation().applyInverseTo(Vector3D.PLUS_J); Vector3D originalZ = attitude.getRotation().applyInverseTo(Vector3D.PLUS_K); Assert.assertEquals(FastMath.cos(rate * dt), Vector3D.dotProduct(shiftedX, originalX), 1.0e-10); Assert.assertEquals(FastMath.sin(rate * dt), Vector3D.dotProduct(shiftedX, originalY), 1.0e-10); Assert.assertEquals(0.0, Vector3D.dotProduct(shiftedX, originalZ), 1.0e-10); Assert.assertEquals(-FastMath.sin(rate * dt), Vector3D.dotProduct(shiftedY, originalX), 1.0e-10); Assert.assertEquals(FastMath.cos(rate * dt), Vector3D.dotProduct(shiftedY, originalY), 1.0e-10); Assert.assertEquals(0.0, Vector3D.dotProduct(shiftedY, originalZ), 1.0e-10); Assert.assertEquals(0.0, Vector3D.dotProduct(shiftedZ, originalX), 1.0e-10); Assert.assertEquals(0.0, Vector3D.dotProduct(shiftedZ, originalY), 1.0e-10); Assert.assertEquals(1.0, Vector3D.dotProduct(shiftedZ, originalZ), 1.0e-10); Vector3D forward = AngularCoordinates.estimateRate(attitude.getRotation(), shifted.getRotation(), dt); Assert.assertEquals(0.0, forward.subtract(attitude.getSpin()).getNorm(), 1.0e-10); Vector3D reversed = AngularCoordinates.estimateRate(shifted.getRotation(), attitude.getRotation(), dt); Assert.assertEquals(0.0, reversed.add(attitude.getSpin()).getNorm(), 1.0e-10); }
From source file:org.orekit.attitudes.BodyCenterPointingTest.java
/** Test if body center belongs to the direction pointed by the satellite *///from www . j a v a2s . c om @Test public void testBodyCenterInPointingDirection() throws OrekitException { // Transform satellite position to position/velocity parameters in EME2000 frame PVCoordinates pvSatEME2000 = circ.getPVCoordinates(); // Pointing direction // ******************** // Get satellite attitude rotation, i.e rotation from EME2000 frame to satellite frame Rotation rotSatEME2000 = earthCenterAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation(); // Transform Z axis from satellite frame to EME2000 Vector3D zSatEME2000 = rotSatEME2000.applyInverseTo(Vector3D.PLUS_K); // Transform Z axis from EME2000 to ITRF2008 Vector3D zSatITRF2008C = eme2000ToItrf.transformVector(zSatEME2000); // Transform satellite position/velocity from EME2000 to ITRF2008 PVCoordinates pvSatITRF2008C = eme2000ToItrf.transformPVCoordinates(pvSatEME2000); // Line containing satellite point and following pointing direction Line pointingLine = new Line(pvSatITRF2008C.getPosition(), pvSatITRF2008C.getPosition().add(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, zSatITRF2008C), 2.0e-8); // Check that the line contains Earth center Assert.assertTrue(pointingLine.contains(Vector3D.ZERO)); }
From source file:org.orekit.attitudes.FixedRateTest.java
@Test public void testZeroRate() throws OrekitException { AbsoluteDate date = new AbsoluteDate(new DateComponents(2004, 3, 2), new TimeComponents(13, 17, 7.865), TimeScalesFactory.getUTC()); final Frame frame = FramesFactory.getEME2000(); FixedRate law = new FixedRate(new Attitude(date, frame, new Rotation(0.48, 0.64, 0.36, 0.48, false), Vector3D.ZERO, Vector3D.ZERO)); PVCoordinates pv = new PVCoordinates(new Vector3D(28812595.32012577, 5948437.4640250085, 0), new Vector3D(0, 0, 3680.853673522056)); Orbit orbit = new KeplerianOrbit(pv, frame, date, 3.986004415e14); Rotation attitude0 = law.getAttitude(orbit, date, frame).getRotation(); Assert.assertEquals(0, Rotation.distance(attitude0, law.getReferenceAttitude().getRotation()), 1.0e-10); Rotation attitude1 = law.getAttitude(orbit.shiftedBy(10.0), date.shiftedBy(10.0), frame).getRotation(); Assert.assertEquals(0, Rotation.distance(attitude1, law.getReferenceAttitude().getRotation()), 1.0e-10); Rotation attitude2 = law.getAttitude(orbit.shiftedBy(20.0), date.shiftedBy(20.0), frame).getRotation(); Assert.assertEquals(0, Rotation.distance(attitude2, law.getReferenceAttitude().getRotation()), 1.0e-10); }
From source file:org.orekit.attitudes.FixedRateTest.java
@Test public void testNonZeroRate() throws OrekitException { final AbsoluteDate date = new AbsoluteDate(new DateComponents(2004, 3, 2), new TimeComponents(13, 17, 7.865), TimeScalesFactory.getUTC()); final double rate = 2 * FastMath.PI / (12 * 60); final Frame frame = FramesFactory.getEME2000(); FixedRate law = new FixedRate(new Attitude(date, frame, new Rotation(0.48, 0.64, 0.36, 0.48, false), new Vector3D(rate, Vector3D.PLUS_K), Vector3D.ZERO)); PVCoordinates pv = new PVCoordinates(new Vector3D(28812595.32012577, 5948437.4640250085, 0), new Vector3D(0, 0, 3680.853673522056)); Orbit orbit = new KeplerianOrbit(pv, FramesFactory.getEME2000(), date, 3.986004415e14); Rotation attitude0 = law.getAttitude(orbit, date, frame).getRotation(); Assert.assertEquals(0, Rotation.distance(attitude0, law.getReferenceAttitude().getRotation()), 1.0e-10); Rotation attitude1 = law.getAttitude(orbit.shiftedBy(10.0), date.shiftedBy(10.0), frame).getRotation(); Assert.assertEquals(10 * rate, Rotation.distance(attitude1, law.getReferenceAttitude().getRotation()), 1.0e-10);/* ww w .j a va2 s . co m*/ Rotation attitude2 = law.getAttitude(orbit.shiftedBy(-20.0), date.shiftedBy(-20.0), frame).getRotation(); Assert.assertEquals(20 * rate, Rotation.distance(attitude2, law.getReferenceAttitude().getRotation()), 1.0e-10); Assert.assertEquals(30 * rate, Rotation.distance(attitude2, attitude1), 1.0e-10); Rotation attitude3 = law.getAttitude(orbit.shiftedBy(0.0), date, frame).getRotation(); Assert.assertEquals(0, Rotation.distance(attitude3, law.getReferenceAttitude().getRotation()), 1.0e-10); }
From source file:org.orekit.attitudes.FixedRateTest.java
@Test public void testSpin() throws OrekitException { AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC()); final double rate = 2 * FastMath.PI / (12 * 60); AttitudeProvider law = new FixedRate(new Attitude(date, FramesFactory.getEME2000(), new Rotation(0.48, 0.64, 0.36, 0.48, false), new Vector3D(rate, Vector3D.PLUS_K), Vector3D.ZERO)); KeplerianOrbit orbit = new KeplerianOrbit(7178000.0, 1.e-4, FastMath.toRadians(50.), FastMath.toRadians(10.), FastMath.toRadians(20.), FastMath.toRadians(30.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, 3.986004415e14); Propagator propagator = new KeplerianPropagator(orbit, law); double h = 0.01; SpacecraftState sMinus = propagator.propagate(date.shiftedBy(-h)); SpacecraftState s0 = propagator.propagate(date); SpacecraftState sPlus = propagator.propagate(date.shiftedBy(h)); // check spin is consistent with attitude evolution double errorAngleMinus = Rotation.distance(sMinus.shiftedBy(h).getAttitude().getRotation(), s0.getAttitude().getRotation()); double evolutionAngleMinus = Rotation.distance(sMinus.getAttitude().getRotation(), s0.getAttitude().getRotation()); Assert.assertEquals(0.0, errorAngleMinus, 1.0e-6 * evolutionAngleMinus); double errorAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.shiftedBy(-h).getAttitude().getRotation()); double evolutionAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.getAttitude().getRotation()); Assert.assertEquals(0.0, errorAnglePlus, 1.0e-6 * evolutionAnglePlus); Vector3D spin0 = s0.getAttitude().getSpin(); Vector3D reference = AngularCoordinates.estimateRate(sMinus.getAttitude().getRotation(), sPlus.getAttitude().getRotation(), 2 * h); Assert.assertEquals(0.0, spin0.subtract(reference).getNorm(), 1.0e-14); }