List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D PLUS_K
Vector3D PLUS_K
To view the source code for org.apache.commons.math3.geometry.euclidean.threed Vector3D PLUS_K.
Click Source Link
From source file:jtrace.scenes.OneCube.java
public static void main(String[] args) throws IOException { Camera camera = new Camera(new Vector3D(0, -2, 1), new Vector3D(0, 0, 0), Vector3D.PLUS_K, 1.0, 1440.0 / 900.0);/*from www . jav a 2 s . c om*/ Scene scene = new Scene(); scene.setCamera(camera); scene.addLightSource(new LightSource(new Vector3D(-3, 3, 3), 4)); scene.addLightSource(new LightSource(new Vector3D(3, -3, 1), 4)); FlatTexture cubeTexture = (new FlatTexture(new SolidPigment(new Colour(0, 0, 1)))); cubeTexture.addFinish(new DiffuseFinish(1.0)); cubeTexture.addFinish(new AmbientFinish(0.1)); //cubeTexture.addFinish(new MirrorFinish(0.2)); Cube cube = new Cube(); //cube.addTransformation(new Scale(0.5)); cube.addTexture(cubeTexture); scene.addObject(cube); FlatTexture floorTexture = new FlatTexture(new ImagePigment(new File("wood.jpg"), 1.0)); floorTexture.addFinish(new DiffuseFinish(1.0)); Plane plane = new Plane(); plane.addTransformation(new Translation(0, 0, -0.5)); plane.addTexture(floorTexture); scene.addObject(plane); BufferedImage image = scene.render(1440, 900, 10); ImageIO.write(image, "PNG", new File("out.png")); }
From source file:jtrace.scenes.JustAPlane.java
public static void main(String[] args) throws IOException { Scene scene = new Scene(); //scene.setBackground(Colour.cyan.mix(0.8, Colour.white)); Camera camera = new Camera(new Vector3D(0, -3, 1), new Vector3D(0, 0, 0), Vector3D.PLUS_K, 1.0, 1440.0 / 900.0);/* w ww . j av a 2s.c o m*/ scene.setCamera(camera); LightSource light = new LightSource(new Vector3D(-3, -3, 3), 4); scene.addLightSource(light); FlatTexture floorTexture = new FlatTexture(new ImagePigment(new File("wood.jpg"), 1.0)); floorTexture.addFinish(new DiffuseFinish(1.0)); floorTexture.addFinish(new AmbientFinish(0.1)); Plane plane = new Plane(); plane.addTexture(floorTexture); plane.addTransformation(new Scale(2, 1, 1)); // plane.addTransformation(new Rotation(Vector3D.PLUS_K, Math.PI/16)); plane.addTransformation(new Rotation(Vector3D.PLUS_J, Math.PI / 16)); // plane.addTransformation(new Translation(0,-0.5,0)); scene.addObject(plane); BufferedImage image = scene.renderWireFrame(1440, 900, 10); ImageIO.write(image, "PNG", new File("out.png")); }
From source file:jtrace.scenes.GlassSphere.java
public static void main(String[] args) throws IOException { Camera camera = new Camera(new Vector3D(0, 0, 2.0), new Vector3D(0, 0, 0), Vector3D.PLUS_J, 1.0, 800.0 / 600.0);//from w w w . j a va 2 s . c o m Scene scene = new Scene(); scene.setCamera(camera); scene.addLightSource(new LightSource(new Vector3D(-1, 3, 1), 4)); FlatTexture sphereTexture = (new FlatTexture(new SolidPigment(new Colour(1, 1, 1)))) .addFinish(new TransparentFinish(1.1)); Sphere sphere = new Sphere(new Vector3D(0, 0, 0), 0.4); sphere.addTexture(sphereTexture); scene.addObject(sphere); FlatTexture floorTexture = (new FlatTexture( new CheckeredPigment(new Colour(.5, .5, .5), new Colour(1, 1, 1), 1))) .addFinish(new DiffuseFinish(1.0)).addFinish(new AmbientFinish(0.05)); Plane plane = new Plane(new Vector3D(0, -0.4, 0), Vector3D.PLUS_J, Vector3D.PLUS_K); plane.addTexture(floorTexture); scene.addObject(plane); BufferedImage image = scene.render(800, 600, 10); ImageIO.write(image, "PNG", new File("out.png")); }
From source file:jtrace.scenes.OneCubeAnimate.java
public static void main(String[] args) throws IOException { Scene scene = new Scene(); scene.addLightSource(new LightSource(new Vector3D(-3, 3, -3), 4)); scene.addLightSource(new LightSource(new Vector3D(6, 6, -3), 4)); FlatTexture cubeTexture = (new FlatTexture(new SolidPigment(new Colour(0, 0, 1)))); cubeTexture.addFinish(new DiffuseFinish(1.0)); cubeTexture.addFinish(new AmbientFinish(0.1)); cubeTexture.addFinish(new MirrorFinish(0.2)); Cube cube = new Cube(new Vector3D(0, 0, 0), 0.5); cube.addTexture(cubeTexture);/*www.j a v a 2s . c o m*/ scene.addObject(cube); // FlatTexture floorTexture = new FlatTexture(new CheckeredPigment( // new Colour(.5,.5,.5), new Colour(1,1,1), 1)); FlatTexture floorTexture = new FlatTexture(new ImagePigment(new File("wood.jpg"), 1.0)); floorTexture.addFinish(new DiffuseFinish(1.0)); Plane plane = new Plane(new Vector3D(0, -0.25, 0), Vector3D.PLUS_J, Vector3D.PLUS_K); plane.addTexture(floorTexture); scene.addObject(plane); Vector3D pointAt = new Vector3D(0, 0, 0); int steps = 100; for (int i = 0; i < steps; i++) { double R = 2.0; double x = R * Math.sin(i * 2 * Math.PI / steps); double z = -R * Math.cos(i * 2 * Math.PI / steps); Camera camera = new Camera(new Vector3D(x, 1, z), pointAt, Vector3D.PLUS_J, 1.0, 800.0 / 600.0); scene.setCamera(camera); BufferedImage image = scene.render(800, 600, 10); ImageIO.write(image, "PNG", new File(String.format("out_%02d.png", i))); } }
From source file:jtrace.scenes.MirroredSphere.java
public static void main(String[] args) throws IOException { Camera camera = new Camera(new Vector3D(-1, 1, 3), new Vector3D(0, 0, 0), Vector3D.PLUS_J, 1.0, 1.6); Scene scene = new Scene(); scene.setCamera(camera);//from w w w .ja v a 2s . c o m scene.addLightSource(new LightSource(new Vector3D(-3, 3, 3), 4)); FlatTexture sphereTexture = (new FlatTexture(new SolidPigment(new Colour(0, 1, 0)))) .addFinish(new AmbientFinish(0.1)).addFinish(new MirrorFinish(0.2)) .addFinish(new DiffuseFinish(0.8)).addFinish(new SpecularFinish(1.0, 100)); Sphere sphere = new Sphere(new Vector3D(0, 0, 0), 0.4); sphere.addTexture(sphereTexture); scene.addObject(sphere); FlatTexture floorTexture = (new FlatTexture( new CheckeredPigment(new Colour(.5, .5, .5), new Colour(1, 1, 1), 1))) .addFinish(new DiffuseFinish(1.0)).addFinish(new AmbientFinish(0.1)); Plane plane = new Plane(new Vector3D(0, -0.4, 0), Vector3D.PLUS_J, Vector3D.PLUS_K); plane.addTexture(floorTexture); scene.addObject(plane); BufferedImage image = scene.render(1440, 900, 10); ImageIO.write(image, "PNG", new File("out.png")); }
From source file:jtrace.scenes.FourSpheres.java
public static void main(String[] args) throws IOException { Camera camera = new Camera(new Vector3D(-1, 2, 5), new Vector3D(0, 0, 0), Vector3D.PLUS_J, 1.0, 1.6); Scene scene = new Scene(); scene.setCamera(camera);//from w ww . j a v a2s . c om scene.addLightSource(new LightSource(new Vector3D(-3, 3, 3), 4)); FlatTexture glossRed = (new FlatTexture(new SolidPigment(new Colour(1, 0, 0)))) .addFinish(new DiffuseFinish(1.0)).addFinish(new AmbientFinish(0.1)) .addFinish(new SpecularFinish(1.0, 100)); FlatTexture glossGreen = (new FlatTexture(new SolidPigment(new Colour(0, 1, 0)))) .addFinish(new DiffuseFinish(1.0)).addFinish(new AmbientFinish(0.1)) .addFinish(new SpecularFinish(1.0, 100)); FlatTexture glossBlue = (new FlatTexture(new SolidPigment(new Colour(0, 0, 1)))) .addFinish(new DiffuseFinish(1.0)).addFinish(new AmbientFinish(0.1)) .addFinish(new SpecularFinish(1.0, 100)); FlatTexture glossYellow = (new FlatTexture(new SolidPigment(new Colour(1, 1, 0)))) .addFinish(new DiffuseFinish(1.0)).addFinish(new AmbientFinish(0.1)) .addFinish(new SpecularFinish(1.0, 100)); Sphere redSphere = new Sphere(new Vector3D(-1, 0, 0), 0.4); redSphere.addTexture(glossRed); scene.addObject(redSphere); Sphere greenSphere = new Sphere(new Vector3D(0, 0, 1), 0.4); greenSphere.addTexture(glossGreen); scene.addObject(greenSphere); Sphere blueSphere = new Sphere(new Vector3D(0, 0, -1), 0.4); blueSphere.addTexture(glossBlue); scene.addObject(blueSphere); Sphere yellowSphere = new Sphere(new Vector3D(1, 0, 0), 0.4); yellowSphere.addTexture(glossYellow); scene.addObject(yellowSphere); FlatTexture floorTexture = new FlatTexture( new CheckeredPigment(new Colour(.5, .5, .5), new Colour(1, 1, 1), 1)); floorTexture.addFinish(new DiffuseFinish(1.0)); floorTexture.addFinish(new AmbientFinish(0.05)); Plane plane = new Plane(new Vector3D(0, -0.4, 0), Vector3D.PLUS_J, Vector3D.PLUS_K); plane.addTexture(floorTexture); scene.addObject(plane); BufferedImage image = scene.render(1440, 900, 10); ImageIO.write(image, "PNG", new File("out.png")); }
From source file:fr.cs.examples.attitude.EarthObservation.java
/** Program entry point. * @param args program arguments (unused here) *///from w ww . ja v a2 s . c o m public static void main(String[] args) { try { // configure Orekit Autoconfiguration.configureOrekit(); final SortedSet<String> output = new TreeSet<String>(); // 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); // Attitudes sequence definition 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 EventDetector dayNightEvent = new EclipseDetector(sun, 696000000., earth, Constants.WGS84_EARTH_EQUATORIAL_RADIUS).withHandler(new ContinueOnEvent<EclipseDetector>()); final EventDetector nightDayEvent = new EclipseDetector(sun, 696000000., earth, Constants.WGS84_EARTH_EQUATORIAL_RADIUS).withHandler(new ContinueOnEvent<EclipseDetector>()); final AttitudesSequence attitudesSequence = new AttitudesSequence(); final AttitudesSequence.SwitchHandler switchHandler = new AttitudesSequence.SwitchHandler() { public void switchOccurred(AttitudeProvider preceding, AttitudeProvider following, SpacecraftState s) { if (preceding == dayObservationLaw) { output.add(s.getDate() + ": switching to night law"); } else { output.add(s.getDate() + ": switching to day law"); } } }; attitudesSequence.addSwitchingCondition(dayObservationLaw, nightRestingLaw, dayNightEvent, false, true, 10.0, AngularDerivativesFilter.USE_R, switchHandler); attitudesSequence.addSwitchingCondition(nightRestingLaw, dayObservationLaw, nightDayEvent, true, false, 10.0, AngularDerivativesFilter.USE_R, switchHandler); if (dayNightEvent.g(new SpacecraftState(initialOrbit)) >= 0) { // initial position is in daytime attitudesSequence.resetActiveProvider(dayObservationLaw); } else { // initial position is in nighttime 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(180.0, new OrekitFixedStepHandler() { public void init(final SpacecraftState s0, final AbsoluteDate t) { } public void handleStep(SpacecraftState currentState, boolean isLast) throws PropagationException { try { DecimalFormatSymbols angleDegree = new DecimalFormatSymbols(Locale.US); angleDegree.setDecimalSeparator('\u00b0'); DecimalFormat ad = new DecimalFormat(" 00.000;-00.000", angleDegree); // the Earth position in spacecraft frame should be along spacecraft Z axis // during nigthtime and away from it during daytime 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 = dayNightEvent.g(currentState); output.add(currentState.getDate() + " " + ad.format(FastMath.toDegrees(eclipseAngle)) + " " + ad.format(FastMath.toDegrees(pointingOffset))); } catch (OrekitException oe) { throw new PropagationException(oe); } } }); // Propagate from the initial date for the fixed duration SpacecraftState finalState = propagator.propagate(initialDate.shiftedBy(12600.)); // we print the lines according to lexicographic order, which is chronological order here // to make sure out of orders calls between step handler and event handlers don't mess things up for (final String line : output) { System.out.println(line); } System.out.println("Propagation ended at " + finalState.getDate()); } catch (OrekitException oe) { System.err.println(oe.getMessage()); } }
From source file:jtrace.object.Plane.java
/** * Create plane that passes through the origin and with a normal pointing * in the positive y direction. The positive u and v directions are the * x and y unit vectors./*from w w w . j a v a2 s .c o m*/ */ public Plane() { super(); this.planeNormal = Vector3D.PLUS_K; this.planeNorth = Vector3D.PLUS_J; this.planeEast = Vector3D.PLUS_I; }
From source file:jtrace.object.Cube.java
/** * Create cube with unit side.//from w w w. j a v a 2s .co 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:jtrace.object.Cube.java
@Override public List<Vector3D[]> getWireFrameObjectFrame() { Vector3D[] vertices = new Vector3D[8]; vertices[0] = new Vector3D(0.5, Vector3D.PLUS_K).add(0.5, Vector3D.PLUS_I).add(0.5, Vector3D.PLUS_J); vertices[1] = new Vector3D(0.5, Vector3D.PLUS_K).subtract(0.5, Vector3D.PLUS_I).add(0.5, Vector3D.PLUS_J); vertices[2] = new Vector3D(0.5, Vector3D.PLUS_K).subtract(0.5, Vector3D.PLUS_I).subtract(0.5, Vector3D.PLUS_J);/*from w w w .j a v a 2 s. c o m*/ vertices[3] = new Vector3D(0.5, Vector3D.PLUS_K).add(0.5, Vector3D.PLUS_I).subtract(0.5, Vector3D.PLUS_J); vertices[4] = new Vector3D(-0.5, Vector3D.PLUS_K).add(0.5, Vector3D.PLUS_I).add(0.5, Vector3D.PLUS_J); vertices[5] = new Vector3D(-0.5, Vector3D.PLUS_K).subtract(0.5, Vector3D.PLUS_I).add(0.5, Vector3D.PLUS_J); vertices[6] = new Vector3D(-0.5, Vector3D.PLUS_K).subtract(0.5, Vector3D.PLUS_I).subtract(0.5, Vector3D.PLUS_J); vertices[7] = new Vector3D(-0.5, Vector3D.PLUS_K).add(0.5, Vector3D.PLUS_I).subtract(0.5, Vector3D.PLUS_J); Vector3D[][] edges = { { vertices[0], vertices[1] }, { vertices[1], vertices[2] }, { vertices[2], vertices[3] }, { vertices[3], vertices[0] }, { vertices[4], vertices[5] }, { vertices[5], vertices[6] }, { vertices[6], vertices[7] }, { vertices[7], vertices[4] }, { vertices[0], vertices[4] }, { vertices[1], vertices[5] }, { vertices[2], vertices[6] }, { vertices[3], vertices[7] } }; return Arrays.asList(edges); }