Public Member Functions | Public Attributes | List of all members
wirecell.util.wires.generator.Rectangle Class Reference
Inheritance diagram for wirecell.util.wires.generator.Rectangle:

Public Member Functions

def __init__ (self, width, height, center=Point(0.0, 0.0))
 
def ll (self)
 
def relative (self, point)
 
def inside (self, point)
 
def toedge (self, point, direction)
 

Public Attributes

 width
 
 height
 
 center
 

Detailed Description

Definition at line 109 of file generator.py.

Constructor & Destructor Documentation

def wirecell.util.wires.generator.Rectangle.__init__ (   self,
  width,
  height,
  center = Point(0.0, 0.0) 
)

Definition at line 110 of file generator.py.

110  def __init__(self, width, height, center = Point(0.0, 0.0)):
111  self.width = width
112  self.height = height
113  self.center = center
114 
def __init__(self, width, height, center=Point(0.0, 0.0))
Definition: generator.py:110

Member Function Documentation

def wirecell.util.wires.generator.Rectangle.inside (   self,
  point 
)

Definition at line 123 of file generator.py.

123  def inside(self, point):
124  r = self.relative(point)
125  return abs(r.x) <= 0.5*self.width and abs(r.y) <= 0.5*self.height
126 
T abs(T value)
def wirecell.util.wires.generator.Rectangle.ll (   self)

Definition at line 116 of file generator.py.

116  def ll(self):
117  return Point(self.center.x - 0.5*self.width,
118  self.center.y - 0.5*self.height);
119 
def wirecell.util.wires.generator.Rectangle.relative (   self,
  point 
)

Definition at line 120 of file generator.py.

120  def relative(self, point):
121  return point - self.center
122 
def wirecell.util.wires.generator.Rectangle.toedge (   self,
  point,
  direction 
)
Return a vector that takes point along direction to the nearest edge.

Definition at line 127 of file generator.py.

127  def toedge(self, point, direction):
128  '''
129  Return a vector that takes point along direction to the nearest edge.
130  '''
131  p1 = self.relative(point)
132  d1 = direction.unit
133 
134  #print "toedge: p1:%s d1:%s" % (p1, d1)
135 
136  corn = Point(0.5*self.width, 0.5*self.height)
137 
138  xdir = d1.dot((1.0, 0.0)) # cos(theta_x)
139  if xdir == 0:
140  tx = None
141  else:
142  xsign = xdir/abs(xdir)
143  dx = xsign*corn.x - p1.x
144  tx = dx/d1.x
145 
146  ydir = d1.dot((0.0, 1.0)) # cos(theta_y)
147  if ydir == 0:
148  ty = None
149  else:
150  ysign = ydir/abs(ydir)
151  dy = ysign*corn.y - p1.y
152  ty = dy/d1.y
153 
154 
155  if ty is None:
156  return d1*tx
157  if tx is None:
158  return d1*ty
159 
160  if tx < ty: # closer to vertical side
161  return d1 * tx
162  return d1 * ty
163 
164 
165 
T abs(T value)
def toedge(self, point, direction)
Definition: generator.py:127

Member Data Documentation

wirecell.util.wires.generator.Rectangle.center

Definition at line 113 of file generator.py.

wirecell.util.wires.generator.Rectangle.height

Definition at line 112 of file generator.py.

wirecell.util.wires.generator.Rectangle.width

Definition at line 111 of file generator.py.


The documentation for this class was generated from the following file: