Package pyllar :: Module Cone
[hide private]
[frames] | no frames]

Source Code for Module pyllar.Cone

 1  """ This is the cone class for Pyllar.""" 
 2  
 
 3  
 
 4  from Plottable import Plottable 
 5  import vtk 
 6  from numpy import * 
 7  
 
8 -class Cone(Plottable):
9 """ The Cone class represents a cone in 3D space. 10 """ 11
12 - def __init__(self, x=0, y=0, z=0, r=1, h=1, res=32):
13 """ Create an instance of the Cone class. 14 15 x, y, and z are the coordinates of the center of the cone. 16 r and h are the radius and height of the cone, respectively. 17 res is the number of polynomials in the angular dimansion. 18 """ 19 20 # create the object 21 self.object = vtk.vtkConeSource() 22 self.object.SetCenter(x, y, z) 23 self.pos = array([x,y,z]) 24 self.direction = array([1.0,0.0,0.0]) 25 self.object.SetRadius(r) 26 self.object.SetHeight(h) 27 self.object.SetResolution(res) 28 29 # create mapper 30 self.mapper = vtk.vtkPolyDataMapper() 31 self.mapper.SetInput(self.object.GetOutput()) 32 33 # create actor 34 self.actor = vtk.vtkActor() 35 self.actor.SetMapper(self.mapper) 36 # self.actor.SetOrigin(self.actor.GetPosition()) 37 38 # add to the axes 39 self.AddToAxes()
40 41 42 43
44 - def SetDirection(self, dir):
45 """ Set the direction vector (vector defining axis of the cone). 46 """ 47 48 self.direction = dir 49 self.object.SetDirection(dir)
50