Class ODE::Mass
In: ext/body.c  (CVS)
Parent: Object

Methods

adjust   allocate   cog   inertia   new   rotate   totalMass   translate  

Classes and Modules

Class ODE::Mass::Box
Class ODE::Mass::CappedCylinder
Class ODE::Mass::Sphere

Public Class methods

allocate() — Allocate a new ODE::Mass object.

[Source]

/*
 * allocate()
 * --
 * Allocate a new ODE::Mass object.
 */
static VALUE
ode_mass_s_alloc( klass )
{
	debugMsg(( "Wrapping an uninitialized ODE::Mass pointer." ));
	return Data_Wrap_Struct( klass, ode_mass_gc_mark, ode_mass_gc_free, 0 );
}

ODE::Mass#initialize( mass ) — Initialize an ODE::Mass object.

[Source]

/*
 * 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;
}

Public Instance methods

adjust( newmass ) or mass=newmass

[Source]

/* 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.

[Source]

/*
 * 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()

[Source]

/* inertia() */
static VALUE
ode_mass_inertia( self )
	 VALUE self;
{
	ode_MASS		*ptr;

	GetMass( self, ptr );
	return ode_matrix3_to_rArray( ptr->massptr->I );
}

rotate( )

[Source]

/* 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.

[Source]

/*
 * 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 );
}

translate( x, y, z )

[Source]

/* translate( x, y, z ) */
static VALUE
ode_mass_translate( self, x, y, z )
	 VALUE self, x, y, z;
{
	ode_MASS		*ptr;

	GetMass( self, ptr );
	dMassTranslate( ptr->massptr, NUM2DBL(x), NUM2DBL(y), NUM2DBL(z) );

	return Qtrue;
}

[Validate]