Search in sources :

Example 11 with Vector3D

use of org.apache.commons.math3.geometry.euclidean.threed.Vector3D in project j6dof-flight-sim by chris-ali.

the class IntegrateGroundReaction method calculateTotalGroundMoments.

/**
 * Calculates each landing gear object's moments about the center of gravity using gear positions relative
 * to the center of gravity and ground reaction forces
 */
private void calculateTotalGroundMoments() {
    double[] tempTotalGroundMoments = new double[] { 0, 0, 0 };
    Vector3D forceVector;
    Vector3D gearRelativeCGVector;
    // i=0 (nose), i=1 (left main), i=2 (right main)
    for (int i = 0; i < 3; i++) {
        // Scale down moments by scaling the arm lengths (negative sign produces realistic braking moments)
        switch(i) {
            case 0:
                gearRelativeCGVector = new Vector3D(new double[] { groundReaction.get(GroundReaction.NOSE_X), groundReaction.get(GroundReaction.NOSE_Y), -groundReaction.get(GroundReaction.NOSE_Z) * 0.125 });
                forceVector = new Vector3D(noseGroundForces);
                break;
            case 1:
                gearRelativeCGVector = new Vector3D(new double[] { groundReaction.get(GroundReaction.LEFT_X), groundReaction.get(GroundReaction.LEFT_Y) * 0.25, -groundReaction.get(GroundReaction.LEFT_Z) * 0.125 });
                forceVector = new Vector3D(leftGroundForces);
                break;
            case 2:
                gearRelativeCGVector = new Vector3D(new double[] { groundReaction.get(GroundReaction.RIGHT_X), groundReaction.get(GroundReaction.RIGHT_Y) * 0.25, -groundReaction.get(GroundReaction.RIGHT_Z) * 0.125 });
                forceVector = new Vector3D(rightGroundForces);
                break;
            default:
                gearRelativeCGVector = new Vector3D(new double[] { 0, 0, 0 });
                forceVector = new Vector3D(new double[] { 0, 0, 0 });
                break;
        }
        // Take the cross product of force and arm vectors and add them to total moments
        for (int j = 0; j < tempTotalGroundMoments.length; j++) tempTotalGroundMoments[j] += Vector3D.crossProduct(forceVector, gearRelativeCGVector).toArray()[j];
    }
    // Saturate ground moments if forward speed is less than 10 ft/sec
    if (linearVelocities[0] < 10) {
        tempTotalGroundMoments[0] = (tempTotalGroundMoments[0] > 100) ? 100 : (tempTotalGroundMoments[0] < -100) ? -100 : tempTotalGroundMoments[0];
        tempTotalGroundMoments[1] = (tempTotalGroundMoments[1] > 100) ? 100 : (tempTotalGroundMoments[1] < -100) ? -100 : tempTotalGroundMoments[1];
        tempTotalGroundMoments[2] = (tempTotalGroundMoments[1] > 100) ? 100 : (tempTotalGroundMoments[1] < -100) ? -100 : tempTotalGroundMoments[1];
    }
    totalGroundMoments = tempTotalGroundMoments;
}
Also used : Vector3D(org.apache.commons.math3.geometry.euclidean.threed.Vector3D)

Example 12 with Vector3D

use of org.apache.commons.math3.geometry.euclidean.threed.Vector3D in project imagej-ops by imagej.

the class TriangularFacet method computeArea.

/**
 * Compute the area of this facet.
 */
private void computeArea() {
    Vector3D cross = vertices.get(0).subtract(vertices.get(1)).crossProduct(vertices.get(2).subtract(vertices.get(0)));
    area = cross.getNorm() * 0.5;
}
Also used : Vector3D(org.apache.commons.math3.geometry.euclidean.threed.Vector3D)

Example 13 with Vector3D

use of org.apache.commons.math3.geometry.euclidean.threed.Vector3D in project imagej-ops by imagej.

the class CentroidMesh method calculate.

@Override
public RealLocalizable calculate(final Mesh input) {
    double c_x = 0;
    double c_y = 0;
    double c_z = 0;
    for (int i = 0; i < input.getFacets().size(); i++) {
        TriangularFacet f = (TriangularFacet) input.getFacets().get(i);
        Vector3D normal = f.getNormal();
        Vector3D a = f.getP0();
        Vector3D b = f.getP1();
        Vector3D c = f.getP2();
        c_x += (1 / 24d) * normal.getX() * (Math.pow((a.getX() + b.getX()), 2) + Math.pow((b.getX() + c.getX()), 2) + Math.pow((c.getX() + a.getX()), 2));
        c_y += (1 / 24d) * normal.getY() * (Math.pow((a.getY() + b.getY()), 2) + Math.pow((b.getY() + c.getY()), 2) + Math.pow((c.getY() + a.getY()), 2));
        c_z += (1 / 24d) * normal.getZ() * (Math.pow((a.getZ() + b.getZ()), 2) + Math.pow((b.getZ() + c.getZ()), 2) + Math.pow((c.getZ() + a.getZ()), 2));
    }
    double d = 1 / (2 * sizeFunc.calculate(input).get());
    c_x *= d;
    c_y *= d;
    c_z *= d;
    return new RealPoint(-c_x, -c_y, -c_z);
}
Also used : TriangularFacet(net.imagej.ops.geom.geom3d.mesh.TriangularFacet) Vector3D(org.apache.commons.math3.geometry.euclidean.threed.Vector3D) RealPoint(net.imglib2.RealPoint) RealPoint(net.imglib2.RealPoint)

Aggregations

Vector3D (org.apache.commons.math3.geometry.euclidean.threed.Vector3D)13 Engine (com.chrisali.javaflightsim.simulation.propulsion.Engine)2 File (java.io.File)2 IOException (java.io.IOException)2 PrintStream (java.io.PrintStream)2 TriangularFacet (net.imagej.ops.geom.geom3d.mesh.TriangularFacet)2 Vertex (net.imagej.ops.geom.geom3d.mesh.Vertex)2 RealPoint (net.imglib2.RealPoint)2 GeodeticPoint (org.orekit.bodies.GeodeticPoint)2 ZipJarCrawler (org.orekit.data.ZipJarCrawler)2 OrekitException (org.orekit.errors.OrekitException)2 Frame (org.orekit.frames.Frame)2 CartesianOrbit (org.orekit.orbits.CartesianOrbit)2 AbsoluteDate (org.orekit.time.AbsoluteDate)2 DateComponents (org.orekit.time.DateComponents)2 TimeComponents (org.orekit.time.TimeComponents)2 TimeScale (org.orekit.time.TimeScale)2 DefaultMesh (net.imagej.ops.geom.geom3d.mesh.DefaultMesh)1 Facet (net.imagej.ops.geom.geom3d.mesh.Facet)1 FinalInterval (net.imglib2.FinalInterval)1