topical media & game development
student-ar-org-papervision3d-core-math-BoundingSphere.ax
student-ar-org-papervision3d-core-math-BoundingSphere.ax
[swf]
[flash]
flex
package org.papervision3d.core.math
{
import org.papervision3d.core.geom.renderables.Vertex3D;
public class @ax-student-ar-org-papervision3d-core-math-BoundingSphere
{
//The non squared maximum vertex distance.
public var maxDistance:Number;
//The squared maximum vertex distance.
public var radius:Number;
@Author Ralph Hauwert
public function @ax-student-ar-org-papervision3d-core-math-BoundingSphere(maxDistance:Number)
{
this.maxDistance = maxDistance;
this.radius = Math.sqrt(maxDistance);
}
public static function getFromVertices(vertices:Array):@ax-student-ar-org-papervision3d-core-math-BoundingSphere
{
var max :Number = 0;
var d :Number;
var v:Vertex3D;
for each(v in vertices )
{
d = v.x*v.x + v.y*v.y + v.z*v.z;
max = (d > max)? d : max;
}
return new @ax-student-ar-org-papervision3d-core-math-BoundingSphere(max);
}
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.