package dev.lumareth.improvedAerodynamics.flight; /** * Sum of the forces and torques of a set of surfaces, in ship axes. Torques of forces are taken about the center of * mass; pure torques (Warium's ship relative rotations) are kept apart since VS scales them differently. */ final class Wrench { final double[] force = new double[3]; final double[] forceTorque = new double[3]; final double[] torque = new double[3]; void clear() { for (int i = 0; i < 3; i++) { force[i] = 0.0; forceTorque[i] = 0.0; torque[i] = 0.0; } } /** Force on the surface's block, with r the block center relative to the center of mass. */ void addForce(double[] r, double x, double y, double z) { force[0] += x; force[1] += y; force[2] += z; forceTorque[0] += r[1] * z - r[2] * y; forceTorque[1] += r[2] * x - r[0] * z; forceTorque[2] += r[0] * y - r[1] * x; } void addTorque(double x, double y, double z) { torque[0] += x; torque[1] += y; torque[2] += z; } double totalTorque(int axis) { return forceTorque[axis] + torque[axis]; } }