7 // A RigidBody object maintains all "internal" state about an object,
8 // accumulates force and torque information from external sources, and
9 // calculates the resulting accelerations.
12 // Units note: obviously, the choice of mass, time and distance units
13 // is up to the user. If you provide mass in kilograms, forces in
14 // newtons, and torques in newton-meters, you'll get your
15 // accelerations back in m/s^2. The angular units, however, are
16 // UNIFORMLY radians. Angular velocities are radians per <time unit>,
17 // the angular acceleration you get back is radians per <time unit>^2,
18 // and the angular momenta supplied to setGyro must be in radians,
19 // too. Radians, not degrees. Don't forget.
27 // Adds a point mass to the system. Returns a handle so the gyro
28 // can be later modified via setMass().
29 int addMass(float mass, float* pos);
31 // Modifies a previously-added point mass (fuel tank running dry,
32 // gear going up, swing wing swinging, pilot bailing out, etc...)
33 void setMass(int handle, float mass);
34 void setMass(int handle, float mass, float* pos);
37 float getMass(int handle);
38 void getMassPosition(int handle, float* out);
41 // The velocity, in local coordinates, of the specified point on a
42 // body rotating about its c.g. with velocity rot.
43 void pointVelocity(float* pos, float* rot, float* out);
45 // Sets the "gyroscope" for the body. This is the total
46 // "intrinsic" angular momentum of the body; that is, rotations of
47 // sub-objects, NOT rotation of the whole body within the global
48 // frame. Because angular momentum is additive in this way, we
49 // don't need to specify specific gyro objects; just add all their
50 // momenta together and set it here.
51 void setGyro(float* angularMomentum);
54 // When masses are moved or changed, this object needs to
55 // regenerate its internal tables. This step is expensive, so
56 // it's exposed to the client who can amortize the call across
60 // Resets the current force/torque parameters to zero.
64 // Applies a force at the specified position.
65 void addForce(float* pos, float* force);
67 // Applies a force at the center of gravity.
68 void addForce(float* force);
70 // Adds a torque with the specified axis and magnitude
71 void addTorque(float* torque);
73 // Sets the rotation rate of the body (about its c.g.) within the
74 // surrounding environment. This is needed to compute torque on
75 // the body due to the centripetal forces involved in the
76 // rotation. NOTE: the rotation vector, like all other
77 // coordinates used here, is specified IN THE LOCAL COORDINATE
79 void setBodySpin(float* rotation);
83 // Returns the center of gravity of the masses, in the body
85 void getCG(float* cgOut);
87 // Returns the acceleration of the body's c.g. relative to the
88 // rest of the world, specified in local coordinates.
89 void getAccel(float* accelOut);
91 // Returns the acceleration of a specific location in local
92 // coordinates. If the body is rotating, this will be different
93 // from the c.g. acceleration due to the centripetal accelerations
94 // of points not on the rotation axis.
95 void getAccel(float* pos, float* accelOut);
97 // Returns the instantaneous rate of change of the angular
98 // velocity, as a vector in local coordinates.
99 void getAngularAccel(float* accelOut);
102 struct Mass { float m; float p[3]; };
104 // Internal "rotational structure"
112 // Inertia tensor, and its inverse. Computed from the above.
116 // Externally determined quantities
122 }; // namespace yasim
123 #endif // _RIGIDBODY_HPP