List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D MINUS_I
Vector3D MINUS_I
To view the source code for org.apache.commons.math3.geometry.euclidean.threed Vector3D MINUS_I.
Click Source Link
From source file:fr.cs.examples.frames.Frames3.java
public static void main(String[] args) { try {//from w w w .j a va 2 s. c o m // configure Orekit and printing format Autoconfiguration.configureOrekit(); // Initial state definition : // ========================== // Date // **** AbsoluteDate initialDate = new AbsoluteDate(new DateComponents(1970, 04, 07), TimeComponents.H00, TimeScalesFactory.getUTC()); // Orbit // ***** // The Sun is in the orbital plane for raan ~ 202 double mu = 3.986004415e+14; // gravitation coefficient Frame eme2000 = FramesFactory.getEME2000(); // inertial frame Orbit orbit = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.), FastMath.toRadians(220.), FastMath.toRadians(5.300), PositionAngle.MEAN, eme2000, initialDate, mu); // Attitude laws // ************* // Earth Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true); BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, earthFrame); // Target pointing attitude provider over satellite nadir at date, without yaw compensation NadirPointing nadirLaw = new NadirPointing(eme2000, earth); // Target pointing attitude provider with yaw compensation final PVCoordinatesProvider sun = CelestialBodyFactory.getSun(); YawSteering yawSteeringLaw = new YawSteering(eme2000, nadirLaw, sun, Vector3D.MINUS_I); // Propagator : Eckstein-Hechler analytic propagator Propagator propagator = new EcksteinHechlerPropagator(orbit, yawSteeringLaw, 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); // Let's write the results in a file in order to draw some plots. propagator.setMasterMode(10, new OrekitFixedStepHandler() { PrintStream out = null; public void init(SpacecraftState s0, AbsoluteDate t) throws PropagationException { try { File file = new File(System.getProperty("user.home"), "XYZ.dat"); System.out.println("Results written to file: " + file.getAbsolutePath()); out = new PrintStream(file); out.println("#time X Y Z Wx Wy Wz"); } catch (IOException ioe) { throw new PropagationException(ioe, LocalizedFormats.SIMPLE_MESSAGE, ioe.getLocalizedMessage()); } } public void handleStep(SpacecraftState currentState, boolean isLast) throws PropagationException { try { // get the transform from orbit/attitude reference frame to spacecraft frame Transform inertToSpacecraft = currentState.toTransform(); // get the position of the Sun in orbit/attitude reference frame Vector3D sunInert = sun.getPVCoordinates(currentState.getDate(), currentState.getFrame()) .getPosition(); // convert Sun position to spacecraft frame Vector3D sunSat = inertToSpacecraft.transformPosition(sunInert); // and the spacecraft rotational rate also Vector3D spin = inertToSpacecraft.getRotationRate(); // Lets calculate the reduced coordinates double sunX = sunSat.getX() / sunSat.getNorm(); double sunY = sunSat.getY() / sunSat.getNorm(); double sunZ = sunSat.getZ() / sunSat.getNorm(); out.format(Locale.US, "%s %12.3f %12.3f %12.3f %12.7f %12.7f %12.7f%n", currentState.getDate(), sunX, sunY, sunZ, spin.getX(), spin.getY(), spin.getZ()); if (isLast) { out.close(); } } catch (OrekitException oe) { throw new PropagationException(oe); } } }); System.out.println("Running..."); propagator.propagate(initialDate.shiftedBy(6000)); } catch (OrekitException oe) { System.err.println(oe.getMessage()); } }
From source file:jtrace.object.Cube.java
/** * Create cube with unit side./*from ww w.j a va2 s. c o m*/ */ public Cube() { super(); normals = new Ray[6]; for (int i = 0; i < 6; i++) normals[i] = new Ray(); normals[0].origin = new Vector3D(0.5, Vector3D.PLUS_I); normals[1].origin = new Vector3D(0.5, Vector3D.MINUS_I); normals[2].origin = new Vector3D(0.5, Vector3D.PLUS_J); normals[3].origin = new Vector3D(0.5, Vector3D.MINUS_J); normals[4].origin = new Vector3D(0.5, Vector3D.PLUS_K); normals[5].origin = new Vector3D(0.5, Vector3D.MINUS_K); normals[0].direction = Vector3D.PLUS_I; normals[1].direction = Vector3D.MINUS_I; normals[2].direction = Vector3D.PLUS_J; normals[3].direction = Vector3D.MINUS_J; normals[4].direction = Vector3D.PLUS_K; normals[5].direction = Vector3D.MINUS_K; }
From source file:org.jtrfp.trcl.gpu.Model.java
public static Model buildCube(double w, double h, double d, TextureDescription tunnelTexturePalette, double[] origin, double u0, double v0, double u1, double v1, boolean hasAlpha, boolean hasNorm, TR tr) { Model m = new Model(false, tr); // Front// w ww. j a va 2s. c om m.addTriangles(Triangle.quad2Triangles( new double[] { 0 - origin[0], w - origin[0], w - origin[0], 0 - origin[0] }, new double[] { h - origin[1], h - origin[1], 0 - origin[1], 0 - origin[1] }, new double[] { 0 - origin[2], 0 - origin[2], 0 - origin[2], 0 - origin[2] }, new double[] { u0, u1, u1, u0 }, new double[] { v1, v1, v0, v0 }, tunnelTexturePalette, RenderMode.STATIC, hasAlpha, hasNorm ? Vector3D.MINUS_K : Vector3D.ZERO, "Model.buildCube.front")); // Left m.addTriangles(Triangle.quad2Triangles( new double[] { 0 - origin[0], 0 - origin[0], 0 - origin[0], 0 - origin[0] }, new double[] { h - origin[1], h - origin[1], 0 - origin[1], 0 - origin[1] }, new double[] { 0 - origin[2], d - origin[2], d - origin[2], 0 - origin[2] }, new double[] { u0, u1, u1, u0 }, new double[] { v1, v1, v0, v0 }, tunnelTexturePalette, RenderMode.STATIC, hasAlpha, hasNorm ? Vector3D.MINUS_I : Vector3D.ZERO, "Model.buildCube.left")); // Right m.addTriangles(Triangle.quad2Triangles( new double[] { w - origin[0], w - origin[0], w - origin[0], w - origin[0] }, new double[] { h - origin[1], h - origin[1], 0 - origin[1], 0 - origin[1] }, new double[] { 0 - origin[2], d - origin[2], d - origin[2], 0 - origin[2] }, new double[] { u0, u1, u1, u0 }, new double[] { v1, v1, v0, v0 }, tunnelTexturePalette, RenderMode.STATIC, hasAlpha, hasNorm ? Vector3D.PLUS_I : Vector3D.ZERO, "Model.buildCube.right")); // Back m.addTriangles(Triangle.quad2Triangles( new double[] { 0 - origin[0], w - origin[0], w - origin[0], 0 - origin[0] }, new double[] { 0 - origin[1], 0 - origin[1], h - origin[1], h - origin[1] }, new double[] { d - origin[2], d - origin[2], d - origin[2], d - origin[2] }, new double[] { u0, u1, u1, u0 }, new double[] { v0, v0, v1, v1 }, tunnelTexturePalette, RenderMode.STATIC, hasAlpha, hasNorm ? Vector3D.PLUS_K : Vector3D.ZERO, "Model.buildCube.back")); return m; }
From source file:org.jtrfp.trcl.Tunnel.java
public Tunnel(TR tr, TDFFile.Tunnel sourceTunnel, LoadingProgressReporter rootReporter) { super(tr.getDefaultGrid()); this.world = tr.getWorld(); reporters = rootReporter.generateSubReporters(2); this.sourceTunnel = sourceTunnel; this.tr = tr; gl = tr.gpu.get().getGl();//from w ww . j ava 2 s. c o m tunnelAssemblyReporter = reporters[0]; Vector3D tunnelEnd = null; deactivate();// Sleep until activated by tunnel entrance try { lvl = tr.getResourceManager().getLVL(sourceTunnel.getTunnelLVLFile()); final Vector3D entranceVector = TUNNEL_START_DIRECTION.getHeading(); palette = tr.getResourceManager().getPalette(lvl.getGlobalPaletteFile()); palette[0] = new Color(0, 0, 0, 0);//KLUDGE: Color zero must be transparent. paletteVL = new ColorPaletteVectorList(palette); ESTuTvPalette = new ColorPaletteVectorList( tr.getResourceManager().getLTE("FOG\\" + lvl.getLuminanceMapFile()).toColors(palette)); tunnelEnd = buildTunnel(sourceTunnel, entranceVector, false); } catch (Exception e) { e.printStackTrace(); } exitObject = new TunnelExitObject(tr, this); exitObject.setMirrorTerrain(sourceTunnel.getExitMode() == ExitMode.exitToChamber); exitObject.setPosition(tunnelEnd.add(new Vector3D(50000, 0, 0)).toArray()); exitObject.notifyPositionChange(); add(exitObject); // X is tunnel depth, Z is left-right try { objectSystem = new ObjectSystem(this, tr, lvl, null, Vector3D.MINUS_I, TUNNEL_START_POS.add(TUNNEL_OBJECT_POS_OFFSET), reporters[1]); } catch (Exception e) { e.printStackTrace(); } /*tr.getGame().getCurrentMission().getOverworldSystem().add( entranceObject = new TunnelEntranceObject(tr, this));*/ }
From source file:org.orekit.attitudes.YawSteeringTest.java
@Test public void testTarget() throws OrekitException { // Attitude laws // ************** // Target pointing attitude provider without yaw compensation NadirPointing nadirLaw = new NadirPointing(circOrbit.getFrame(), earthShape); // Target pointing attitude provider with yaw compensation YawSteering yawCompensLaw = new YawSteering(circOrbit.getFrame(), nadirLaw, CelestialBodyFactory.getSun(), Vector3D.MINUS_I); // Check observed ground point // ***************************** TimeStampedPVCoordinates noYawObserved = nadirLaw.getTargetPV(circOrbit, date, itrf); // with yaw compensation TimeStampedPVCoordinates yawObserved = yawCompensLaw.getTargetPV(circOrbit, date, itrf); // Check difference PVCoordinates observedDiff = new PVCoordinates(yawObserved, noYawObserved); Assert.assertEquals(0.0, observedDiff.getPosition().getNorm(), Utils.epsilonTest); Assert.assertEquals(0.0, observedDiff.getVelocity().getNorm(), Utils.epsilonTest); Assert.assertEquals(0.0, observedDiff.getAcceleration().getNorm(), Utils.epsilonTest); }
From source file:org.orekit.attitudes.YawSteeringTest.java
@Test public void testSunAligned() throws OrekitException { // Attitude laws // ************** // Target pointing attitude provider over satellite nadir at date, without yaw compensation NadirPointing nadirLaw = new NadirPointing(circOrbit.getFrame(), earthShape); // Target pointing attitude provider with yaw compensation PVCoordinatesProvider sun = CelestialBodyFactory.getSun(); YawSteering yawCompensLaw = new YawSteering(circOrbit.getFrame(), nadirLaw, sun, Vector3D.MINUS_I); // Get sun direction in satellite frame Rotation rotYaw = yawCompensLaw.getAttitude(circOrbit, date, circOrbit.getFrame()).getRotation(); Vector3D sunEME2000 = sun.getPVCoordinates(date, FramesFactory.getEME2000()).getPosition(); Vector3D sunSat = rotYaw.applyTo(sunEME2000); // Check sun is in (X,Z) plane Assert.assertEquals(0.0, FastMath.sin(sunSat.getAlpha()), 1.0e-7); }
From source file:org.orekit.attitudes.YawSteeringTest.java
@Test public void testCompensAxis() throws OrekitException { // Attitude laws // ************** // Target pointing attitude provider over satellite nadir at date, without yaw compensation NadirPointing nadirLaw = new NadirPointing(circOrbit.getFrame(), earthShape); // Target pointing attitude provider with yaw compensation YawSteering yawCompensLaw = new YawSteering(circOrbit.getFrame(), nadirLaw, CelestialBodyFactory.getSun(), Vector3D.MINUS_I); // Get attitude rotations from non yaw compensated / yaw compensated laws Rotation rotNoYaw = nadirLaw.getAttitude(circOrbit, date, circOrbit.getFrame()).getRotation(); Rotation rotYaw = yawCompensLaw.getAttitude(circOrbit, date, circOrbit.getFrame()).getRotation(); // Compose rotations composition Rotation compoRot = rotYaw.applyTo(rotNoYaw.revert()); Vector3D yawAxis = compoRot.getAxis(); // Check axis Assert.assertEquals(0., yawAxis.getX(), Utils.epsilonTest); Assert.assertEquals(0., yawAxis.getY(), Utils.epsilonTest); Assert.assertEquals(1., yawAxis.getZ(), Utils.epsilonTest); }
From source file:org.orekit.attitudes.YawSteeringTest.java
/** Test the derivatives of the sliding target */// w ww . j ava 2 s . co m @Test public void testSlidingDerivatives() throws OrekitException { GroundPointing law = new YawSteering(circOrbit.getFrame(), new NadirPointing(circOrbit.getFrame(), earthShape), CelestialBodyFactory.getSun(), Vector3D.MINUS_I); List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>(); for (double dt = -0.1; dt < 0.1; dt += 0.05) { Orbit o = circOrbit.shiftedBy(dt); sample.add(law.getTargetPV(o, o.getDate(), o.getFrame())); } TimeStampedPVCoordinates reference = TimeStampedPVCoordinates.interpolate(circOrbit.getDate(), CartesianDerivativesFilter.USE_P, sample); TimeStampedPVCoordinates target = law.getTargetPV(circOrbit, circOrbit.getDate(), circOrbit.getFrame()); Assert.assertEquals(0.0, Vector3D.distance(reference.getPosition(), target.getPosition()), 1.0e-15 * reference.getPosition().getNorm()); Assert.assertEquals(0.0, Vector3D.distance(reference.getVelocity(), target.getVelocity()), 4.0e-11 * reference.getVelocity().getNorm()); Assert.assertEquals(0.0, Vector3D.distance(reference.getAcceleration(), target.getAcceleration()), 8.0e-6 * reference.getAcceleration().getNorm()); }
From source file:org.orekit.attitudes.YawSteeringTest.java
@Test public void testSpin() throws OrekitException { NadirPointing nadirLaw = new NadirPointing(circOrbit.getFrame(), earthShape); // Target pointing attitude provider with yaw compensation AttitudeProvider law = new YawSteering(circOrbit.getFrame(), nadirLaw, CelestialBodyFactory.getSun(), Vector3D.MINUS_I); 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.shiftedBy(-300.0), 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-9 * 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-9 * evolutionAnglePlus); Vector3D spin0 = s0.getAttitude().getSpin(); Vector3D reference = AngularCoordinates.estimateRate(sMinus.getAttitude().getRotation(), sPlus.getAttitude().getRotation(), 2 * h); Assert.assertTrue(spin0.getNorm() > 1.0e-3); Assert.assertEquals(0.0, spin0.subtract(reference).getNorm(), 4.0e-13); }
From source file:org.orekit.bodies.EllipsoidTest.java
@Test public void testPrincipalPlanesIntersections() { final Ellipsoid ellipsoid = new Ellipsoid(FramesFactory.getEME2000(), 1, 2, 3); final Ellipse xy = ellipsoid.getPlaneSection(Vector3D.ZERO, Vector3D.PLUS_K); Assert.assertEquals(0, Vector3D.distance(Vector3D.ZERO, xy.getCenter()), 1.0e-15); checkPrincipalAxes(xy, Vector3D.PLUS_J, Vector3D.MINUS_I); Assert.assertEquals(2.0, xy.getA(), 1.0e-15); Assert.assertEquals(1.0, xy.getB(), 1.0e-15); Assert.assertTrue(xy.getFrame() == ellipsoid.getFrame()); Assert.assertEquals(0.0, errorOnEllipsoid(xy, ellipsoid), 1.0e-15); Assert.assertEquals(0.0, errorOnPlane(xy, Vector3D.ZERO, Vector3D.PLUS_K), 1.0e-15); final Ellipse yz = ellipsoid.getPlaneSection(Vector3D.ZERO, Vector3D.PLUS_I); Assert.assertEquals(0, Vector3D.distance(Vector3D.ZERO, yz.getCenter()), 1.0e-15); checkPrincipalAxes(yz, Vector3D.PLUS_K, Vector3D.MINUS_J); Assert.assertEquals(3.0, yz.getA(), 1.0e-15); Assert.assertEquals(2.0, yz.getB(), 1.0e-15); Assert.assertTrue(yz.getFrame() == ellipsoid.getFrame()); Assert.assertEquals(0.0, errorOnEllipsoid(yz, ellipsoid), 1.0e-15); Assert.assertEquals(0.0, errorOnPlane(yz, Vector3D.ZERO, Vector3D.PLUS_I), 1.0e-15); final Ellipse zx = ellipsoid.getPlaneSection(Vector3D.ZERO, Vector3D.PLUS_J); Assert.assertEquals(0, Vector3D.distance(Vector3D.ZERO, zx.getCenter()), 1.0e-15); checkPrincipalAxes(zx, Vector3D.PLUS_K, Vector3D.PLUS_I); Assert.assertEquals(3.0, zx.getA(), 1.0e-15); Assert.assertEquals(1.0, zx.getB(), 1.0e-15); Assert.assertTrue(zx.getFrame() == ellipsoid.getFrame()); Assert.assertEquals(0.0, errorOnEllipsoid(zx, ellipsoid), 1.0e-15); Assert.assertEquals(0.0, errorOnPlane(zx, Vector3D.ZERO, Vector3D.PLUS_J), 1.0e-15); }