Class | ODE::Mass::Box |
In: |
ext/mass.c
(CVS)
|
Parent: | ODE::Mass |
ODE::Mass::Box#initialize( density, sideX, sideY, sideZ[, totalmass] ) — Create and return a box Mass of the given dimensions and density, with the center of mass at (0,0,0) relative to the body. If the optional totalmass parameter is given, adjust the values so the total mass is totalmass before returning.
/* * ODE::Mass::Box#initialize( density, sideX, sideY, sideZ[, totalmass] ) * -- * Create and return a box Mass of the given dimensions and density, with the * center of mass at (0,0,0) relative to the body. If the optional * <tt>totalmass</tt> parameter is given, adjust the values so the total mass is * <tt>totalmass</tt> before returning. */ static VALUE ode_mass_box_init( argc, argv, self ) int argc; VALUE *argv, self; { ode_MASS *ptr; VALUE density, lx, ly, lz, totalmass; rb_scan_args( argc, argv, "41", &density, &lx, &ly, &lz, &totalmass ); CheckPositiveNonZeroNumber( NUM2DBL(density), "density" ); CheckPositiveNonZeroNumber( NUM2DBL(lx), "sideX" ); CheckPositiveNonZeroNumber( NUM2DBL(ly), "sideY" ); CheckPositiveNonZeroNumber( NUM2DBL(lz), "sideZ" ); rb_call_super( 0, 0 ); ptr = get_mass( self ); dMassSetBox( ptr->massptr, NUM2DBL(density), NUM2DBL(lx), NUM2DBL(ly), NUM2DBL(lz) ); /* 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; }