11# -*- coding: utf-8 -*-
22
3- from __future__ import absolute_import , division
4-
53import math
6- from builtins import map , object
7-
8- from past .builtins import xrange
9- from past .utils import old_div
104
115from . import cartesian3d as c3d
126
@@ -15,8 +9,9 @@ class BoundingSphere(object):
159 def __init__ (self , * args , ** kwargs ):
1610 MAX = float ('infinity' )
1711 MIN = float ('-infinity' )
18- self .center = list (map (float , kwargs .get ('center' , [])))
19- self .radius = float (kwargs .get ('radius' , 0 ))
12+
13+ self .center = kwargs .get ('center' , [])
14+ self .radius = kwargs .get ('radius' , 0 )
2015 self .minPointX = [MAX , MAX , MAX ]
2116 self .minPointY = [MAX , MAX , MAX ]
2217 self .minPointZ = [MAX , MAX , MAX ]
@@ -31,7 +26,7 @@ def fromPoints(self, points):
3126 if nbPositions < 2 :
3227 raise Exception ('Your list of points must contain at least 2 points' )
3328
34- for i in xrange (0 , nbPositions ):
29+ for i in range (0 , nbPositions ):
3530 point = points [i ]
3631
3732 # Store the points containing the smallest and largest component
@@ -86,7 +81,7 @@ def fromPoints(self, points):
8681 naiveCenter = c3d .multiplyByScalar (c3d .add (minBoxPt , maxBoxPt ), 0.5 )
8782 naiveRadius = 0.0
8883
89- for i in xrange (0 , nbPositions ):
84+ for i in range (0 , nbPositions ):
9085 currentP = points [i ]
9186
9287 # Find the furthest point from the naive center to calculate the naive radius.
@@ -104,12 +99,12 @@ def fromPoints(self, points):
10499 # Calculate center of new Ritter sphere
105100 oldToNew = oldCenterToPoint - ritterRadius
106101 ritterCenter = [
107- old_div (( ritterRadius * ritterCenter [0 ] + oldToNew * currentP [ 0 ]),
108- oldCenterToPoint ) ,
109- old_div (( ritterRadius * ritterCenter [1 ] + oldToNew * currentP [ 1 ]),
110- oldCenterToPoint ) ,
111- old_div (( ritterRadius * ritterCenter [2 ] + oldToNew * currentP [ 2 ]),
112- oldCenterToPoint )
102+ ( ritterRadius * ritterCenter [0 ] +
103+ oldToNew * currentP [ 0 ]) / oldCenterToPoint ,
104+ ( ritterRadius * ritterCenter [1 ] +
105+ oldToNew * currentP [ 1 ]) / oldCenterToPoint ,
106+ ( ritterRadius * ritterCenter [2 ] +
107+ oldToNew * currentP [ 2 ]) / oldCenterToPoint
113108 ]
114109
115110 # Keep the naive sphere if smaller
0 commit comments