1 """ The sphere class for Pyllar."""
2
3
4
5 from Plottable import Plottable
6 import vtk
7 from numpy import *
8
10 """ The Sphere class represents a sphere in 3D space.
11 """
12
13 - def __init__(self, x=0, y=0, z=0, r=1, thetaRes=32, phiRes=32):
14 """ Create an instance of the Sphere class.
15
16 x, y, and z are the coordinates of the center of the sphere.
17 thetaRes is the number of polynomials in the theta dimansion.
18 phiRes is the number of polynomials in the phi dimansion.
19 """
20
21
22 self.object = vtk.vtkSphereSource()
23 self.object.SetCenter(x, y, z)
24 self.pos = array([x,y,z])
25 self.direction = array([0.0,1.0,0.0])
26 self.object.SetRadius(r)
27 self.object.SetThetaResolution(thetaRes)
28 self.object.SetPhiResolution(phiRes)
29
30
31 self.mapper = vtk.vtkPolyDataMapper()
32 self.mapper.SetInput(self.object.GetOutput())
33
34
35 self.actor = vtk.vtkActor()
36 self.actor.SetMapper(self.mapper)
37
38
39 self.AddToAxes()
40