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;
}
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;
}
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);
}
Aggregations