]> Dogcows Code - chaz/yoink/blobdiff - src/moof/rigid_body.hh
remove some unused stlplus modules
[chaz/yoink] / src / moof / rigid_body.hh
index 65e502c8483ae1530c594882b1adb4e1258254f1..67e12ddce4d4b87e1a48e7b17816cf3806c63bb5 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_RIGID_BODY_HH_
 #define _MOOF_RIGID_BODY_HH_
@@ -34,34 +32,28 @@ struct linear_state
 {
        typedef moof::vector< scalar, fixed<D> > vector;
        typedef boost::function<const vector& (const linear_state&)>
-                                                                                                       force_function;
+               force_function;
 
        // primary
-       
        vector          position;
        vector          momentum;
 
        // secondary
-
        vector          velocity;
 
        // user
-
        vector          force;
        std::vector<force_function> forces;
 
        // constant
-       
        scalar          mass;
        scalar          inverse_mass;
 
-
        void recalculate()
        {
                velocity = momentum * inverse_mass;
        }
 
-
        struct gravity_force
        {
                explicit gravity_force(scalar a = -9.8)
@@ -76,14 +68,12 @@ struct linear_state
                        return force;
                }
 
-
        private:
 
                vector force;
                scalar acceleration;
        };
 
-
        void init()
        {
                position.zero();
@@ -98,7 +88,6 @@ struct linear_state
                inverse_mass = 1.0 / mass;
        }
 
-
        struct derivative
        {
                vector  velocity;
@@ -121,7 +110,6 @@ struct linear_state
                }
        };
 
-
        vector total_force() const
        {
                vector f(force);
@@ -148,30 +136,24 @@ struct linear_state
        }
 };
 
-
 struct rotational_state2
 {
        // primary
-
        scalar          orientation;
        scalar          angular_momentum;
 
        // secondary
-
        scalar          angularVelocity;
 
        // constant
-
        scalar          inertia;
        scalar          inverse_inertia;
 
-
        void recalculate()
        {
                angularVelocity = angular_momentum * inertia;
        }
 
-
        struct derivative
        {
                scalar  angularVelocity;
@@ -189,21 +171,17 @@ struct rotational_state2
 struct rotational_state3
 {
        // primary
-
        quaternion      orientation;
        vector3         angular_momentum;
 
        // secondary
-
        quaternion      spin;
        vector3         angularVelocity;
 
        // constant
-
        scalar          inertia;
        scalar          inverse_inertia;
 
-
        void recalculate()
        {
                angularVelocity = angular_momentum * inertia;
@@ -239,7 +217,6 @@ struct state3 : public linear_state<3>, public rotational_state3
        }
 };
 
-
 template <class T>
 inline T interpolate(const T& a, const T& b, scalar alpha)
 {
@@ -247,37 +224,34 @@ inline T interpolate(const T& a, const T& b, scalar alpha)
 }
 
 template <>
-inline state2 interpolate<state2>(const state2& a, const state2& b,
-                                                                 scalar alpha)
+inline state2
+interpolate<state2>(const state2& a, const state2& b, scalar alpha)
 {
        state2 state(b);
        state.position = interpolate(a.position, b.position, alpha);
        state.momentum = interpolate(a.momentum, b.momentum, alpha);
        state.orientation = interpolate(a.orientation, b.orientation, alpha);
        state.angular_momentum = interpolate(a.angular_momentum,
-                                                                               b.angular_momentum, alpha);
+                       b.angular_momentum, alpha);
        return state;
 }
 
 template <>
-inline state3 interpolate<state3>(const state3& a, const state3& b,
-                                                                 scalar alpha)
+inline state3
+interpolate<state3>(const state3& a, const state3& b, scalar alpha)
 {
        state3 state(b);
        state.position = interpolate(a.position, b.position, alpha);
        state.momentum = interpolate(a.momentum, b.momentum, alpha);
        state.orientation = slerp(a.orientation, b.orientation, alpha);
        state.angular_momentum = interpolate(a.angular_momentum,
-                                                                               b.angular_momentum, alpha);
+                       b.angular_momentum, alpha);
        return state;
 }
 
-
-
 /**
  * Interface for anything that can move.
  */
-
 template <class T>
 class rigid_body : public entity
 {
This page took 0.024947 seconds and 4 git commands to generate.