# Diameter of an Instance?

Is there a Panda function/method for returning the overall diameter of an object/actor?

I need an overall diameter calculation based on the object/actor’s tight bounds.

You should be able to calculate the width, height and depth of the tight bounds by subtracting the x-, z- and y- components of the max- and min- points provided by calcTightBounds, I believe. Something like this:

``````# Presume that the NodePath in question is called "myNP"

minPt = Point3()
maxPt = Point3()

myNP.calcTightBounds(minPt, maxPt)

width = abs(maxPt.x - minPt.x)``````

As I understand it, an object’s “tight bounds” are represented by a box, so it doesn’t really have a diameter; if you are confident that your object is spherical, however, then the width, height or depth, as described above, should at the least approximate the sphere’s diameter.

If, on the other hand, you want the diameter of a sphere that passes through the corners of the tight-bounds box, then the following might work – I haven’t checked for any issues that it might miss, I’m afraid:

``````# Presume that the NodePath in question is called "myNP"

minPt = Point3()
maxPt = Point3()

myNP.calcTightBounds(minPt, maxPt)

diff = maxPt - minPt

diameter = diff.length()``````