| Class | ODE::Mass |
| In: |
ext/body.c
(CVS)
|
| Parent: | Object |
ODE::Mass#initialize( mass ) — Initialize an ODE::Mass object.
/*
* ODE::Mass#initialize( mass )
* --
* Initialize an ODE::Mass object.
*/
static VALUE
ode_mass_init( argc, argv, self )
int argc;
VALUE *argv, self;
{
ode_MASS *ptr;
VALUE mass;
if ( !(ptr = check_mass(self)) ) {
DATA_PTR(self) = ptr = ode_mass_alloc();
}
/* Set the mode if it was specified. */
if ( rb_scan_args(argc, argv, "01", &mass) ) {
CheckPositiveNonZeroNumber( NUM2DBL(mass), "mass" );
dMassAdjust( ptr->massptr, (dReal)NUM2DBL(mass) );
}
rb_call_super( 0, 0 );
return self;
}
adjust( newmass ) or mass=newmass
/* adjust( newmass ) or mass=newmass */
static VALUE
ode_mass_adjust( self, newmass )
VALUE self, newmass;
{
ode_MASS *ptr;
GetMass( self, ptr );
dMassAdjust( ptr->massptr, NUM2DBL(newmass) );
return Qtrue;
}
ODE::Mass#centerOfGravity — Return the center of gravity position in the body frame as an ODE::Position.
/*
* ODE::Mass#centerOfGravity
* --
* Return the center of gravity position in the body frame as an ODE::Position.
*/
static VALUE
ode_mass_cog( self )
VALUE self;
{
ode_MASS *ptr = get_mass( self );
VALUE pos;
Vec3ToOdePosition( ptr->massptr->c, pos );
return pos;
}
inertia()
/* inertia() */
static VALUE
ode_mass_inertia( self )
VALUE self;
{
ode_MASS *ptr;
GetMass( self, ptr );
return ode_matrix3_to_rArray( ptr->massptr->I );
}
rotate( )
/* rotate( ) */
static VALUE
ode_mass_rotate( self, rotation )
VALUE self, rotation;
{
ode_MASS *ptr;
dMatrix3 dmatrix;
if ( ! rb_obj_is_kind_of(rotation, ode_cOdeQuaternion) )
rb_raise( rb_eTypeError, "no implicit conversion from %s",
rb_class2name(CLASS_OF( rotation )) );
/* Get the dMatrix3 from the quaternion object and use it to rotate the
mass */
GetMass( self, ptr );
ode_quaternion_to_dMatrix3( rotation, dmatrix );
dMassRotate( ptr->massptr, dmatrix );
return Qtrue;
}
ODE::Mass#totalMass — Return the total mass of the body this mass applies to.
/*
* ODE::Mass#totalMass
* --
* Return the total mass of the body this mass applies to.
*/
static VALUE
ode_mass_totalmass( self )
VALUE self;
{
ode_MASS *ptr = get_mass( self );
return rb_float_new( ptr->massptr->mass );
}