Public Member Functions | Public Attributes | List of all members
wirecell.util.geo.shapes.Rectangle2D Class Reference
Inheritance diagram for wirecell.util.geo.shapes.Rectangle2D:

Public Member Functions

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

Public Attributes

 width
 
 height
 
 center
 

Detailed Description

An 2D rectangle

Definition at line 125 of file shapes.py.

Constructor & Destructor Documentation

def wirecell.util.geo.shapes.Rectangle2D.__init__ (   self,
  width,
  height,
  center = Point2D(0.0, 0.0) 
)

Definition at line 129 of file shapes.py.

129  def __init__(self, width, height, center = Point2D(0.0, 0.0)):
130  self.width = width
131  self.height = height
132  self.center = center
133 
def __init__(self, width, height, center=Point2D(0.0, 0.0))
Definition: shapes.py:129

Member Function Documentation

def wirecell.util.geo.shapes.Rectangle2D.inside (   self,
  point2d 
)

Definition at line 142 of file shapes.py.

142  def inside(self, point2d):
143  r = self.relative(point2d)
144  return abs(r.x) <= 0.5*self.width and abs(r.y) <= 0.5*self.height
145 
def relative(self, point2d)
Definition: shapes.py:139
T abs(T value)
def wirecell.util.geo.shapes.Rectangle2D.ll (   self)

Definition at line 135 of file shapes.py.

135  def ll(self):
136  return Point(self.center.x - 0.5*self.width,
137  self.center.y - 0.5*self.height);
138 
def wirecell.util.geo.shapes.Rectangle2D.relative (   self,
  point2d 
)

Definition at line 139 of file shapes.py.

139  def relative(self, point2d):
140  return point2d - self.center
141 
def relative(self, point2d)
Definition: shapes.py:139
def wirecell.util.geo.shapes.Rectangle2D.toedge (   self,
  point,
  direction 
)
Return a vector that takes point along direction to the nearest edge.

Definition at line 146 of file shapes.py.

146  def toedge(self, point, direction):
147  '''
148  Return a vector that takes point along direction to the nearest edge.
149  '''
150  p1 = self.relative(point)
151  d1 = direction.unit
152 
153  #print "toedge: p1:%s d1:%s" % (p1, d1)
154 
155  xdir = d1.dot((1.0, 0.0)) # cos(theta_x)
156  xsign = xdir/abs(xdir)
157  ydir = d1.dot((0.0, 1.0)) # cos(theta_y)
158  ysign = ydir/abs(ydir)
159 
160  corn = Point(0.5*self.width, 0.5*self.height)
161 
162  dx = xsign*corn.x - p1.x
163  dy = ysign*corn.y - p1.y
164 
165  tx = dx/d1.x
166  ty = dy/d1.y
167 
168 
169  if tx < ty: # closer to vertical side
170  jump = tx
171  else:
172  jump = ty
173 
174  return d1 * jump
175 
176 

Member Data Documentation

wirecell.util.geo.shapes.Rectangle2D.center

Definition at line 132 of file shapes.py.

wirecell.util.geo.shapes.Rectangle2D.height

Definition at line 131 of file shapes.py.

wirecell.util.geo.shapes.Rectangle2D.width

Definition at line 130 of file shapes.py.


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