| Class | ODE::Geometry::Sphere |
| In: |
ext/geometry.c
(CVS)
|
| Parent: | ODE::Geometry::Placeable |
ODE::Geometry::Sphere::new( radius, space=nil ) — Create a new spherical collision geometry with the specified radius, inserting it into the specified space, if given.
/*
* ODE::Geometry::Sphere::new( radius, space=nil )
* --
* Create a new spherical collision geometry with the specified radius,
* inserting it into the specified space, if given.
*/
static VALUE
ode_geometry_sphere_init( argc, argv, self )
int argc;
VALUE *argv, self;
{
VALUE radius, spaceObj;
dSpaceID space = 0;
ode_GEOMETRY *geometry = 0;
debugMsg(( "Calling super()" ));
rb_call_super( 0, 0 );
debugMsg(( "Back from super()" ));
/* Fetch the ode_GEOMETRY pointer */
geometry = get_geom( self );
if ( !geometry ) rb_bug( "Superclass's initialize didn't return a valid Geometry." );
debugMsg(( "Sphere::initialize: Geometry is <%p>", geometry ));
debugMsg(( "Sphere::initialize: Scanning arguments." ));
if ( rb_scan_args(argc, argv, "11", &radius, &spaceObj) == 2 ) {
SetContainer( spaceObj, space, geometry );
}
CheckPositiveNonZeroNumber( NUM2DBL(radius), "radius" );
debugMsg(( "Creating new Sphere geometry." ));
geometry->id = (dGeomID)dCreateSphere( space, (dReal)NUM2DBL(radius) );
/* Set the ode_GEOMETRY pointer as the data pointer of the dGeomID */
dGeomSetData( geometry->id, geometry );
return self;
}
ODE::Geometry::Sphere#radius — Get the sphere’s radius.
/*
* ODE::Geometry::Sphere#radius
* --
* Get the sphere's radius.
*/
static VALUE
ode_geometry_sphere_radius( self )
VALUE self;
{
ode_GEOMETRY *geometry = get_geom(self);
return rb_float_new( (dReal)dGeomSphereGetRadius(geometry->id) );
}
ODE::Geometry::Sphere#radius=( newValue ) — Set the sphere’s radius.
/*
* ODE::Geometry::Sphere#radius=( newValue )
* --
* Set the sphere's radius.
*/
static VALUE
ode_geometry_sphere_radius_eq( self, newRadius )
VALUE self, newRadius;
{
ode_GEOMETRY *geometry = get_geom( self );
CheckPositiveNonZeroNumber( NUM2DBL(newRadius), "radius" );
dGeomSphereSetRadius( geometry->id, (dReal)NUM2DBL(newRadius) );
return rb_float_new( (dReal)dGeomSphereGetRadius(geometry->id) );
}