List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D crossProduct
public Vector3D crossProduct(final Vector<Euclidean3D> v)
From source file:com.mapr.synth.drive.GeoPoint.java
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); }//from ww w. ja va2 s. co m ux = ux.normalize(); return ux; }
From source file:nova.minecraft.wrapper.mc.forge.v17.wrapper.redstone.backward.BWRedstone.java
public BWRedstone() { this.canConnect = (Redstone otherRedstone) -> { Block otherBlock = ((Block) otherRedstone.getProvider()); Vector3D otherPos = otherBlock.position(); Vector3D thisPos = block().position(); return block().mcBlock.canConnectRedstone(mcWorld(), otherBlock.x(), otherBlock.y(), otherBlock.z(), Direction.fromVector(thisPos.crossProduct(otherPos)).ordinal()); };/*w ww.ja v a 2 s.c o m*/ }
From source file:nova.minecraft.wrapper.mc.forge.v18.wrapper.redstone.backward.BWRedstone.java
public BWRedstone() { this.canConnect = (Redstone otherRedstone) -> { Block otherBlock = ((Block) otherRedstone.getProvider()); Vector3D otherPos = otherBlock.position(); Vector3D thisPos = block().position(); return block().mcBlock.canConnectRedstone(mcWorld(), Game.natives().toNative(thisPos), Game.natives().toNative(Direction.fromVector(thisPos.crossProduct(otherPos)))); };// w w w . ja v a 2s.c o m }
From source file:nova.minecraft.wrapper.mc.forge.v1_11.wrapper.redstone.backward.BWRedstone.java
public BWRedstone() { this.canConnect = (Redstone otherRedstone) -> { Block otherBlock = ((Block) otherRedstone.getProvider()); Vector3D otherPos = otherBlock.position(); Vector3D thisPos = block().position(); BlockPos pos = new BlockPos(block().x(), block().y(), block().z()); return block().mcBlock.canConnectRedstone(mcWorld().getBlockState(pos), mcWorld(), pos, Game.natives().toNative(Direction.fromVector(thisPos.crossProduct(otherPos)))); };/* ww w . j a v a 2s.c o m*/ }
From source file:org.gearvrf.keyboard.util.Util.java
public static void rotateWithOpenGLLookAt(Vector3D cameraVector, Vector3D parentVector, GVRSceneObject object) { Vector3D globalUpVector = new Vector3D(0, 1, 0); Vector3D lookVector = parentVector.normalize(); Vector3D rightVector = lookVector.crossProduct(globalUpVector); Vector3D upVector = rightVector.crossProduct(lookVector); Vector3D zAxis = cameraVector.subtract(parentVector).normalize(); // Vector3D xAxis = upVector.crossProduct(zAxis).normalize(); Vector3D xAxis = zAxis.crossProduct(upVector).normalize(); Vector3D yAxis = xAxis.crossProduct(zAxis).normalize(); // Vector3D yAxis = xAxis.crossProduct(zAxis).normalize(); zAxis = zAxis.scalarMultiply(-1.f);/*from ww w .j a v a2s . c o m*/ float angle = (float) Vector3D.angle(parentVector, cameraVector); angle = (float) Math.toDegrees(angle); object.getTransform().rotateByAxis(angle, (float) xAxis.getX(), (float) xAxis.getY(), (float) xAxis.getZ()); object.getTransform().rotateByAxis(angle, (float) yAxis.getX(), (float) yAxis.getY(), (float) yAxis.getZ()); object.getTransform().rotateByAxis(angle, (float) zAxis.getX(), (float) zAxis.getY(), (float) zAxis.getZ()); }
From source file:org.gearvrf.scene_objects.GVRCylinderSceneObject.java
private void createBody(float bottomRadius, float topRadius, float height, int stackNumber, int sliceNumber) { float difference = bottomRadius - topRadius; float halfHeight = height / 2.0f; for (int stack = 0; stack < stackNumber; stack++) { int initVertexCount = vertexCount; float stackPercentage0 = ((float) (stack) / stackNumber); float stackPercentage1 = ((float) (stack + 1) / stackNumber); float t0 = 1.0f - stackPercentage0; float t1 = 1.0f - stackPercentage1; float y0 = -halfHeight + (stackPercentage0 * height); float y1 = -halfHeight + (stackPercentage1 * height); float nx, ny, nz; for (int slice = 0; slice < sliceNumber; slice++) { float slicePercentage0 = ((float) (slice) / sliceNumber); float slicePercentage1 = ((float) (slice + 1) / sliceNumber); double theta0 = slicePercentage0 * 2.0 * Math.PI; double theta1 = slicePercentage1 * 2.0 * Math.PI; double cosTheta0 = Math.cos(theta0); double sinTheta0 = Math.sin(theta0); double cosTheta1 = Math.cos(theta1); double sinTheta1 = Math.sin(theta1); float radius = (bottomRadius - (difference * stackPercentage0)); float x0 = (float) (radius * cosTheta0); float z0 = (float) (-radius * sinTheta0); float x1 = (float) (radius * cosTheta1); float z1 = (float) (-radius * sinTheta1); radius = (bottomRadius - (difference * stackPercentage1)); float x2 = (float) (radius * cosTheta0); float z2 = (float) (-radius * sinTheta0); float x3 = (float) (radius * cosTheta1); float z3 = (float) (-radius * sinTheta1); float s0 = slicePercentage0; float s1 = slicePercentage1; vertices[vertexCount + 0] = x0; vertices[vertexCount + 1] = y0; vertices[vertexCount + 2] = z0; vertices[vertexCount + 3] = x1; vertices[vertexCount + 4] = y0; vertices[vertexCount + 5] = z1; vertices[vertexCount + 6] = x2; vertices[vertexCount + 7] = y1; vertices[vertexCount + 8] = z2; vertices[vertexCount + 9] = x3; vertices[vertexCount + 10] = y1; vertices[vertexCount + 11] = z3; // calculate normal Vector3D v1 = new Vector3D(x1 - x0, 0, z1 - z0); Vector3D v2 = new Vector3D(x2 - x0, y1 - y0, z2 - z0); Vector3D v3 = v1.crossProduct(v2).normalize(); nx = (float) v3.getX(); ny = (float) v3.getY(); nz = (float) v3.getZ(); normals[vertexCount + 0] = nx; normals[vertexCount + 1] = ny; normals[vertexCount + 2] = nz; normals[vertexCount + 3] = nx; normals[vertexCount + 4] = ny; normals[vertexCount + 5] = nz; normals[vertexCount + 6] = nx; normals[vertexCount + 7] = ny; normals[vertexCount + 8] = nz; normals[vertexCount + 9] = nx; normals[vertexCount + 10] = ny; normals[vertexCount + 11] = nz; texCoords[texCoordCount + 0] = s0; texCoords[texCoordCount + 1] = t0; texCoords[texCoordCount + 2] = s1; texCoords[texCoordCount + 3] = t0; texCoords[texCoordCount + 4] = s0; texCoords[texCoordCount + 5] = t1; texCoords[texCoordCount + 6] = s1; texCoords[texCoordCount + 7] = t1; indices[indexCount + 0] = (char) (triangleCount + 0); // 0 indices[indexCount + 1] = (char) (triangleCount + 1); // 1 indices[indexCount + 2] = (char) (triangleCount + 2); // 2 indices[indexCount + 3] = (char) (triangleCount + 2); // 2 indices[indexCount + 4] = (char) (triangleCount + 1); // 1 indices[indexCount + 5] = (char) (triangleCount + 3); // 3 vertexCount += 12;/*from w w w . j a v a2s . c o m*/ texCoordCount += 8; indexCount += 6; triangleCount += 4; } for (int i = initVertexCount; i < vertexCount - 12; i += 12) { Vector3D v1 = new Vector3D(normals[i + 3], normals[i + 4], normals[i + 5]); Vector3D v2 = new Vector3D(normals[i + 12], normals[i + 13], normals[i + 14]); Vector3D v3 = v1.add(v2).normalize(); nx = (float) v3.getX(); ny = (float) v3.getY(); nz = (float) v3.getZ(); normals[i + 3] = nx; normals[i + 4] = ny; normals[i + 5] = nz; normals[i + 12] = nx; normals[i + 13] = ny; normals[i + 14] = nz; v1 = new Vector3D(normals[i + 9], normals[i + 10], normals[i + 11]); v2 = new Vector3D(normals[i + 18], normals[i + 19], normals[i + 20]); v3 = v1.add(v2).normalize(); nx = (float) v3.getX(); ny = (float) v3.getY(); nz = (float) v3.getZ(); normals[i + 9] = nx; normals[i + 10] = ny; normals[i + 11] = nz; normals[i + 18] = nx; normals[i + 19] = ny; normals[i + 20] = nz; } int i1 = vertexCount - 12; Vector3D v1 = new Vector3D(normals[i1 + 3], normals[i1 + 4], normals[i1 + 5]); int i2 = initVertexCount; Vector3D v2 = new Vector3D(normals[i2 + 0], normals[i2 + 1], normals[i2 + 2]); Vector3D v3 = v1.add(v2).normalize(); nx = (float) v3.getX(); ny = (float) v3.getY(); nz = (float) v3.getZ(); normals[i1 + 3] = nx; normals[i1 + 4] = ny; normals[i1 + 5] = nz; normals[i2 + 0] = nx; normals[i2 + 1] = ny; normals[i2 + 2] = nz; v1 = new Vector3D(normals[i1 + 9], normals[i1 + 10], normals[i1 + 11]); v2 = new Vector3D(normals[i2 + 6], normals[i2 + 7], normals[i2 + 8]); v3 = v1.add(v2).normalize(); nx = (float) v3.getX(); ny = (float) v3.getY(); nz = (float) v3.getZ(); normals[i1 + 9] = nx; normals[i1 + 10] = ny; normals[i1 + 11] = nz; normals[i2 + 6] = nx; normals[i2 + 7] = ny; normals[i2 + 8] = nz; } }
From source file:org.jtrfp.trcl.beh.AutoLeveling.java
@Override public void _tick(long timeInMillis) { final WorldObject parent = getParent(); final Vector3D oldHeading = parent.getHeading(); final Vector3D oldTop = parent.getTop(); final Vector3D oldCross = oldHeading.crossProduct(oldTop); final Vector3D newHeading = levelingAxis == LevelingAxis.HEADING ? new Vector3D( oldHeading.getX() * retainmentCoeff[0] + levelingVector.getX() * inverseRetainmentCoeff[0], oldHeading.getY() * retainmentCoeff[1] + levelingVector.getY() * inverseRetainmentCoeff[1], oldHeading.getZ() * retainmentCoeff[2] + levelingVector.getZ() * inverseRetainmentCoeff[2]) .normalize() : oldHeading.normalize();//from www.j a va 2 s. c om final Vector3D newTop = levelingAxis == LevelingAxis.TOP ? new Vector3D( oldTop.getX() * retainmentCoeff[0] + levelingVector.getX() * inverseRetainmentCoeff[0], oldTop.getY() * retainmentCoeff[1] + levelingVector.getY() * inverseRetainmentCoeff[1], oldTop.getZ() * retainmentCoeff[2] + levelingVector.getZ() * inverseRetainmentCoeff[2]).normalize() : oldTop.normalize(); final Vector3D newCross = levelingAxis == LevelingAxis.CROSS ? new Vector3D( oldCross.getX() * retainmentCoeff[0] + levelingVector.getX() * inverseRetainmentCoeff[0], oldCross.getY() * retainmentCoeff[1] + levelingVector.getY() * inverseRetainmentCoeff[1], oldCross.getZ() * retainmentCoeff[2] + levelingVector.getZ() * inverseRetainmentCoeff[2]) .normalize() : oldCross.normalize(); final Rotation topDelta = new Rotation(oldTop, newTop); final Rotation headingDelta = new Rotation(oldHeading, newHeading); final Rotation crossDelta = new Rotation(oldCross, newCross); parent.setHeading(crossDelta.applyTo(headingDelta.applyTo(topDelta.applyTo(oldHeading)))); parent.setTop(crossDelta.applyTo(headingDelta.applyTo(topDelta.applyTo(oldTop)))); }
From source file:org.jtrfp.trcl.beh.HeadingXAlwaysPositiveBehavior.java
@Override public void _tick(long tickTime) { final WorldObject p = getParent(); final Vector3D heading = p.getHeading(); if (heading.getX() < 0) { //Rotate 180 degrees on top axis p.setHeading(new Vector3D(0, heading.getY(), heading.getZ()).normalize()); final Vector3D horiz = p.getHeading().crossProduct(p.getTop()).normalize(); final Vector3D newTop = horiz.crossProduct(p.getHeading()).normalize(); p.setTop(newTop);//from w ww.ja v a 2s . c o m } }
From source file:org.jtrfp.trcl.Tunnel.java
/** * Tunnel items: FANBODY.BIN - fan IRIS.BIN - animated iris BEAM.BIN / * PIPE.BIN JAW1.BIN (right) JAW2.BIN (left) - jaws ELECTRI[0-3].RAW - force * field TP1.RAW - good enough for blastable door? * //from w w w . j a va2s. c o m * @throws IOException * @throws FileLoadException * * */ private void installObstacles(Segment s, ColorPaletteVectorList tunnelColorPalette, ColorPaletteVectorList ESTuTvPalette, TextureDescription[] tunnelTexturePalette, Vector3D heading, Vector3D top, Vector3D wPos, double width, double height, TR tr) throws IllegalAccessException, FileLoadException, IOException { final ColorPaletteVectorList palette = tr.getGlobalPaletteVL(); Obstacle obs = s.getObstacle(); WorldObject wo; Model m; switch (obs) { case none0: break; case doorway: { m = Model.buildCube(tunnelDia, tunnelDia, wallThickness, tunnelTexturePalette[s.getObstacleTextureIndex()], new double[] { tunnelDia / 2., tunnelDia / 2., 0 }, .5, .5, 1, 1, tr); wo = new WorldObject(tr, m); wo.setPosition(wPos.toArray()); wo.setHeading(heading); wo.setTop(top); add(wo); break; } case closedDoor: { BarrierCube bc = new BarrierCube(tr, tunnelDia, tunnelDia, wallThickness, tunnelTexturePalette[s.getObstacleTextureIndex()], new double[] { tunnelDia / 2., tunnelDia / 2., 0 }, .5, .5, 0, 1, false); bc.setPosition(wPos.toArray()); bc.setHeading(heading); bc.addBehavior(new DamageableBehavior().setHealth(4096)); bc.addBehavior(new ExplodesOnDeath(ExplosionType.Blast)); bc.addBehavior(new DeathBehavior()); bc.addBehavior(new DebrisOnDeathBehavior()); bc.addBehavior(new DestructibleWallBehavior()); bc.setTop(top); add(bc); break; } case blownOpenDoor://TODO: This is not displaying alpha BarrierCube bc = new BarrierCube(tr, tunnelDia, tunnelDia, wallThickness, tunnelTexturePalette[s.getObstacleTextureIndex()], new double[] { tunnelDia / 2., tunnelDia / 2., 0 }, .5, .5, 1, 1, true); bc.setPosition(wPos.toArray()); bc.setHeading(heading); bc.setTop(top); add(bc); break; case movingWallLeft: { Vector3D endPos = wPos.add(heading.crossProduct(top).scalarMultiply(tunnelDia)); bc = new BarrierCube(tr, tunnelDia, tunnelDia, wallThickness, tunnelTexturePalette[s.getObstacleTextureIndex()], new double[] { tunnelDia / 2., tunnelDia / 2., 0 }, false); bc.addBehavior(new ShiftingObjectBehavior(3000, wPos, endPos)); bc.setPosition(wPos.toArray()); bc.setHeading(heading); bc.setTop(top); bc.addBehavior(new CubeCollisionBehavior(bc)); add(bc); break; } case movingWallRight: { Vector3D endPos = wPos.subtract(heading.crossProduct(top).scalarMultiply(tunnelDia)); bc = new BarrierCube(tr, tunnelDia, tunnelDia, wallThickness, tunnelTexturePalette[s.getObstacleTextureIndex()], new double[] { tunnelDia / 2., tunnelDia / 2., 0 }, false); bc.addBehavior(new ShiftingObjectBehavior(3000, wPos, endPos)); bc.addBehavior(new CubeCollisionBehavior(bc)); bc.setPosition(wPos.toArray()); bc.setHeading(heading); bc.setTop(top); bc.addBehavior(new CubeCollisionBehavior(bc)); add(bc); break; } case movingWallDown: { Vector3D endPos = wPos.subtract(top.scalarMultiply(tunnelDia)); bc = new BarrierCube(tr, tunnelDia, tunnelDia, wallThickness, tunnelTexturePalette[s.getObstacleTextureIndex()], new double[] { tunnelDia / 2., tunnelDia / 2., 0 }, false); bc.addBehavior(new ShiftingObjectBehavior(3000, wPos, endPos)); bc.setPosition(wPos.toArray()); bc.setHeading(heading); bc.setTop(top); bc.addBehavior(new CubeCollisionBehavior(bc)); add(bc); break; } case movingWallUp: { Vector3D endPos = wPos.add(top.scalarMultiply(tunnelDia)); bc = new BarrierCube(tr, tunnelDia, tunnelDia, wallThickness, tunnelTexturePalette[s.getObstacleTextureIndex()], new double[] { tunnelDia / 2., tunnelDia / 2., 0 }, false); bc.addBehavior(new ShiftingObjectBehavior(3000, wPos, endPos)); bc.setPosition(wPos.toArray()); bc.setHeading(heading); bc.setTop(top); bc.addBehavior(new CubeCollisionBehavior(bc)); add(bc); break; } case wallLeftSTUB: case wallLeft: bc = new BarrierCube(tr, tunnelDia, tunnelDia, wallThickness, tunnelTexturePalette[s.getObstacleTextureIndex()], new double[] { 0., tunnelDia / 2., 0 }, false); bc.setPosition(wPos.toArray()); bc.setHeading(heading); bc.setTop(top); bc.addBehavior(new CubeCollisionBehavior(bc)); add(bc); break; case wallRightSTUB: case wallRight: bc = new BarrierCube(tr, tunnelDia, tunnelDia, wallThickness, tunnelTexturePalette[s.getObstacleTextureIndex()], new double[] { tunnelDia, tunnelDia / 2., 0 }, false); bc.setPosition(wPos.toArray()); bc.setHeading(heading); bc.setTop(top); bc.addBehavior(new CubeCollisionBehavior(bc)); add(bc); break; case wallDownSTUB: case wallDown: bc = new BarrierCube(tr, tunnelDia, tunnelDia, wallThickness, tunnelTexturePalette[s.getObstacleTextureIndex()], new double[] { tunnelDia / 2., tunnelDia / 2., 0 }, false); bc.setPosition((wPos.subtract(top.scalarMultiply(tunnelDia / 2))).toArray()); bc.setHeading(heading); bc.setTop(top); bc.addBehavior(new CubeCollisionBehavior(bc)); add(bc); break; case wallUpSTUB: case wallUp: bc = new BarrierCube(tr, tunnelDia, tunnelDia, wallThickness, tunnelTexturePalette[s.getObstacleTextureIndex()], new double[] { tunnelDia / 2., tunnelDia / 2., 0 }, false); bc.setPosition((wPos.add(top.scalarMultiply(tunnelDia / 2))).toArray()); bc.setHeading(heading); bc.setTop(top); bc.addBehavior(new CubeCollisionBehavior(bc)); add(bc); break; case rotatingHalfWall: { final double rotPeriod = 32768. / (double) s.getRotationSpeed(); final boolean rotate = !Double.isInfinite(rotPeriod); bc = new BarrierCube(tr, tunnelDia, tunnelDia, wallThickness, tunnelTexturePalette[s.getObstacleTextureIndex()], new double[] { 0, tunnelDia / 2., 0 }, false); if (rotate) { bc.addBehavior(new RotatingObjectBehavior(heading, heading, top, (int) (rotPeriod * 1000.), 0)); bc.setTop(top); } else bc.setTop(new Rotation(heading, Math.PI + Math.PI / 2).applyTo(top)); bc.setPosition(wPos.toArray()); bc.setHeading(heading); bc.setTop(top); bc.addBehavior(new CubeCollisionBehavior(bc)); add(bc); break; } case rotating34Wall: { final double rotPeriod = 32768. / (double) s.getRotationSpeed(); final boolean rotate = !Double.isInfinite(rotPeriod); bc = new BarrierCube(tr, tunnelDia, tunnelDia, wallThickness, tunnelTexturePalette[s.getObstacleTextureIndex()], new double[] { 0, tunnelDia / 2., 10 }, false); if (rotate) { bc.addBehavior( new RotatingObjectBehavior(heading, heading, top, (int) (rotPeriod * 1000.), Math.PI)); bc.setTop(top); } else bc.setTop(new Rotation(heading, Math.PI + Math.PI / 2).applyTo(top)); bc.setPosition(wPos.toArray()); bc.setHeading(heading); bc.addBehavior(new CubeCollisionBehavior(bc)); add(bc); bc = new BarrierCube(tr, tunnelDia, tunnelDia, wallThickness, tunnelTexturePalette[s.getObstacleTextureIndex()], new double[] { 0, tunnelDia / 2., 0 }, false); if (rotate) { bc.addBehavior(new RotatingObjectBehavior(heading, heading, top, (int) (rotPeriod * 1000.), Math.PI + Math.PI / 2)); bc.setTop(top); } else bc.setTop(new Rotation(heading, Math.PI * 2).applyTo(top)); bc.setPosition((wPos.add(new Vector3D(100, 0, 0))).toArray()); bc.setHeading(heading); bc.addBehavior(new CubeCollisionBehavior(bc)); add(bc); break; } case fan: wo = new WorldObject(tr, tr.getResourceManager().getBINModel("BLADE.BIN", tunnelTexturePalette[s.getObstacleTextureIndex()], 28, false, palette, ESTuTvPalette)); wo.setPosition(wPos.toArray()); wo.setHeading(heading); wo.setTop(top); wo.addBehavior(new CubeCollisionBehavior(wo)); wo.addBehavior(new RotatingObjectBehavior(heading, heading, top, 6000, Math.random() * 2 * Math.PI)); add(wo); wo = new WorldObject(tr, tr.getResourceManager().getBINModel("FANBODY.BIN", tunnelTexturePalette[s.getObstacleTextureIndex()], 28, false, palette, null));//No ESTuTv for fan for now. wo.setPosition(wPos.toArray()); wo.setHeading(heading); wo.setTop(top); wo.addBehavior(new CubeCollisionBehavior(wo)); add(wo); break; case jawsVertical: // Up jaw wo = new WorldObject(tr, tr.getResourceManager().getBINModel("JAW2.BIN", tunnelTexturePalette[s.getObstacleTextureIndex()], 8, false, palette, ESTuTvPalette)); wo.addBehavior(new ShiftingObjectBehavior(3000, wPos, wPos.add(top.scalarMultiply(tunnelDia / 2)))); wo.addBehavior(new CubeCollisionBehavior(wo)); wo.setPosition(wPos.toArray()); wo.setHeading(heading); wo.setTop(heading.crossProduct(top).negate()); wo.addBehavior(new CubeCollisionBehavior(wo)); add(wo); // Down jaw wo = new WorldObject(tr, tr.getResourceManager().getBINModel("JAW1.BIN", tunnelTexturePalette[s.getObstacleTextureIndex()], 8, false, palette, ESTuTvPalette)); wo.addBehavior( new ShiftingObjectBehavior(3000, wPos, wPos.subtract(top.scalarMultiply(tunnelDia / 2)))); wo.setPosition(wPos.toArray()); wo.setHeading(heading); wo.setTop(heading.crossProduct(top).negate()); wo.addBehavior(new CubeCollisionBehavior(wo)); add(wo); break; case jawsHorizontal: // Left jaw wo = new WorldObject(tr, tr.getResourceManager().getBINModel("JAW2.BIN", tunnelTexturePalette[s.getObstacleTextureIndex()], 8, false, palette, ESTuTvPalette)); wo.addBehavior(new ShiftingObjectBehavior(3000, wPos, wPos.add(heading.crossProduct(top).scalarMultiply(tunnelDia / 2)))); wo.setPosition(wPos.toArray()); wo.setHeading(heading); wo.setTop(top); wo.addBehavior(new CubeCollisionBehavior(wo)); add(wo); // Right jaw wo = new WorldObject(tr, tr.getResourceManager().getBINModel("JAW1.BIN", tunnelTexturePalette[s.getObstacleTextureIndex()], 8, false, palette, ESTuTvPalette)); wo.addBehavior(new ShiftingObjectBehavior(3000, wPos, wPos.subtract(heading.crossProduct(top).scalarMultiply(tunnelDia / 2)))); wo.setPosition(wPos.toArray()); wo.setHeading(heading); wo.setTop(top); wo.addBehavior(new CubeCollisionBehavior(wo)); add(wo); break; case metalBeamUp: wo = new WorldObject(tr, tr.getResourceManager().getBINModel("BEAM.BIN", tunnelTexturePalette[s.getObstacleTextureIndex()], 8, false, palette, ESTuTvPalette)); wo.setPosition(wPos.add(new Vector3D(0, tunnelDia / 6, 0)).toArray()); wo.setHeading(heading); wo.setTop(top); wo.addBehavior(new CubeCollisionBehavior(wo)); add(wo); break; case metalBeamDown: wo = new WorldObject(tr, tr.getResourceManager().getBINModel("BEAM.BIN", tunnelTexturePalette[s.getObstacleTextureIndex()], 8, false, palette, ESTuTvPalette)); wo.setPosition(wPos.add(new Vector3D(0, -tunnelDia / 6, 0)).toArray()); wo.setHeading(heading); wo.setTop(top); wo.addBehavior(new CubeCollisionBehavior(wo)); add(wo); break; case metalBeamLeft: wo = new WorldObject(tr, tr.getResourceManager().getBINModel("BEAM.BIN", tunnelTexturePalette[s.getObstacleTextureIndex()], 8, false, palette, ESTuTvPalette)); wo.setPosition(wPos.add(new Vector3D(-tunnelDia / 6, 0, 0)).toArray()); wo.setHeading(heading); wo.setTop(top.crossProduct(heading)); wo.addBehavior(new CubeCollisionBehavior(wo)); add(wo); break; case metalBeamRight: wo = new WorldObject(tr, tr.getResourceManager().getBINModel("BEAM.BIN", tunnelTexturePalette[s.getObstacleTextureIndex()], 8, false, palette, ESTuTvPalette)); wo.setPosition(wPos.add(new Vector3D(tunnelDia / 6, 0, 0)).toArray()); wo.setHeading(heading); wo.setTop(top.crossProduct(heading)); wo.addBehavior(new CubeCollisionBehavior(wo)); add(wo); break; case forceField: { //ELECTRI[0-3].RAW final ForceField ff = new ForceField(tr, (int) tunnelDia, (int) wallThickness); ff.setPosition(wPos.toArray()); ff.setHeading(heading); ff.setTop(top); add(ff); break; } // Invisible walls, as far as I know, are never used. // This makes sense: There is nothing fun about trying to get through a // tunnel and crashing into invisible walls. case invisibleWallUp:// TODO break; case invisibleWallDown:// TODO break; case invisibleWallLeft:// TODO break; case invisibleWallRight:// TODO break; case iris: { wo = new WorldObject(tr, tr.getResourceManager().getBINModel("IRIS.BIN", tunnelTexturePalette[s.getObstacleTextureIndex()], 4 * 256, false, palette, ESTuTvPalette)); final Model mod = wo.getModel(); wo.addBehavior(new IrisBehavior(new Sequencer(mod.getFrameDelayInMillis(), 2, true), width)); wo.setPosition(wPos.toArray()); wo.setHeading(heading); wo.setTop(top); wo.addBehavior(new CubeCollisionBehavior(wo)); add(wo); break; } }// end switch(obstruction) }
From source file:org.orekit.utils.PVCoordinatesTest.java
@Test public void testGetMomentum() { //setup/*from w w w.j av a2 s .c o m*/ Vector3D p = new Vector3D(1, -2, 3); Vector3D v = new Vector3D(-9, 8, -7); //action + verify Assert.assertEquals(new PVCoordinates(p, v).getMomentum(), p.crossProduct(v)); //check simple cases Assert.assertEquals(new PVCoordinates(Vector3D.PLUS_I, Vector3D.MINUS_I).getMomentum(), Vector3D.ZERO); Assert.assertEquals(new PVCoordinates(Vector3D.PLUS_I, Vector3D.PLUS_J).getMomentum(), Vector3D.PLUS_K); }