v5.0
Returns the center and radius of a bounding sphere of the Geometry object. If an input transform is specified, it is applied to the Geometry before the bounding sphere is calculated.
Object Geometry.GetBoundingSphere( siVolumeCenterMethod in_centerMethod, Object in_pXfoObjectToBSphereSpace ); |
oArray = Geometry.GetBoundingSphere( [Type], [Transform] ); |
1-dimensional Array containing four values: the X, Y and Z coordinates of the center, followed by the radius of the sphere.
Parameter | Type | Description |
---|---|---|
Type | siVolumeCenterMethod |
The technique used to calculate the center of the bounding sphere Default Value: siVolumeCenterMethodBBoxCenter |
Transform | SITransformation | Transform to be applied to the Geometry before the bounding sphere is calculated |
/* Example using no input transform and default center calculation method */ // Create and move (rotate and translate) a torus NewScene( null, false ) ; var oTorus = ActiveSceneRoot.AddGeometry( "Torus", "MeshSurface" ) ; SelectObj( oTorus ) ; Rotate(null, 45, 0, 0, siAbsolute, siPivot, siObj, siX, null, null, null, null, null, null, null, 0, null) ; Translate(null, 3, 2, 1, siAbsolute, siPivot, siObj, siX, null, null, null, null, null, null, null, null, null, 0, null) ; // Find the bounding sphere var vba = new VBArray( oTorus.ActivePrimitive.Geometry.GetBoundingSphere() ) ; var jsa = vba.toArray() ; // Report the (local) center and radius Application.LogMessage( "center:" + jsa[0] + ", " + jsa[1] + ", " + jsa[2] ) ; Application.LogMessage( "radius:" + jsa[3] ) ; |
/* Example using an input transform to preserve scaling and a different center calculation method */ // Create and move (rotate and translate) a torus NewScene( null, false ) ; var oTorus = ActiveSceneRoot.AddGeometry( "Torus", "MeshSurface" ) ; SelectObj( oTorus ) ; Scale(null, 0.5, 0.5, 1, siAbsolute, siGlobal, siObj, siY, null, null, null, null, null, null, null, 0, null) ; oTransform = oTorus.Kinematics.Local.Transform ; // Find the bounding sphere var vba = new VBArray( oTorus.ActivePrimitive.Geometry.GetBoundingSphere( siVolumeCenterMethodCOG, oTransform) ) ; var jsa = vba.toArray() ; // Report the (local) center and radius Application.LogMessage( "center:" + jsa[0] + ", " + jsa[1] + ", " + jsa[2] ) ; Application.LogMessage( "radius:" + jsa[3] ) ; // Build a sphere that shows the bounding volume var oSphere = ActiveSceneRoot.AddPrimitive("Sphere" ) ; oSphere.radius = jsa[3] ; oSphere.PosX = jsa[0] ; oSphere.PosY = jsa[1] ; oSphere.PosZ = jsa[2] ; |