| Class | ODE::Mass::Sphere |
| In: |
ext/mass.c
(CVS)
|
| Parent: | ODE::Mass |
ODE::Mass::Sphere#initialize( radius, density[, totalmass] ) — Given a radius and a density, create a spherical Mass object. If the optional totalmass parameter is given, adjust them so the total mass is totalmass before returning.
/*
* ODE::Mass::Sphere#initialize( radius, density[, totalmass] )
* --
* Given a <tt>radius</tt> and a <tt>density</tt>, create a spherical Mass
* object. If the optional <tt>totalmass</tt> parameter is given, adjust them so
* the total mass is <tt>totalmass</tt> before returning.
*/
static VALUE
ode_mass_sphere_init( argc, argv, self )
int argc;
VALUE *argv, self;
{
ode_MASS *ptr;
VALUE radius, density, totalmass;
rb_scan_args( argc, argv, "21", &radius, &density, &totalmass );
rb_call_super( 0, 0 );
ptr = get_mass( self );
CheckPositiveNonZeroNumber( NUM2DBL(radius), "radius" );
CheckPositiveNonZeroNumber( NUM2DBL(density), "density" );
dMassSetSphere( ptr->massptr, NUM2DBL(radius), NUM2DBL(density) );
/* If a totalmass argument was given, check and set it */
if ( RTEST(totalmass) ) {
CheckPositiveNonZeroNumber( NUM2DBL(totalmass), "totalmass" );
dMassAdjust( ptr->massptr, (dReal)NUM2DBL(totalmass) );
}
return self;
}