Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def bounding_box(self):
xmin = self.vertices.x.min()
xmax = self.vertices.x.max()
ymin = self.vertices.y.min()
ymax = self.vertices.y.max()
return BoundingBox.from_float(xmin, xmax, ymin, ymax)
def bounding_box(self):
"""Bounding box (`~regions.BoundingBox`)."""
xmin = self.center.x - self.radius
xmax = self.center.x + self.radius
ymin = self.center.y - self.radius
ymax = self.center.y + self.radius
return BoundingBox.from_float(xmin, xmax, ymin, ymax)
def bounding_box(self):
return BoundingBox.from_float(self.center.x, self.center.x,
self.center.y, self.center.y)
h2 = self.height / 2.
cos_angle = np.cos(self.angle) # self.angle is a Quantity
sin_angle = np.sin(self.angle) # self.angle is a Quantity
dx1 = abs(w2 * cos_angle - h2 * sin_angle)
dy1 = abs(w2 * sin_angle + h2 * cos_angle)
dx2 = abs(w2 * cos_angle + h2 * sin_angle)
dy2 = abs(w2 * sin_angle - h2 * cos_angle)
dx = max(dx1, dx2)
dy = max(dy1, dy2)
xmin = self.center.x - dx
xmax = self.center.x + dx
ymin = self.center.y - dy
ymax = self.center.y + dy
return BoundingBox.from_float(xmin, xmax, ymin, ymax)
def bounding_box(self):
"""Bounding box (`~regions.BoundingBox`)."""
xmin = min(self.start.x, self.end.x)
xmax = max(self.start.x, self.end.x)
ymin = min(self.start.y, self.end.y)
ymax = max(self.start.y, self.end.y)
return BoundingBox.from_float(xmin, xmax, ymin, ymax)
t1 = np.arctan(self.height / tan_angle / self.width)
t2 = t1 + np.pi * u.rad
dy1 = 0.5 * self.height * cos_angle * np.sin(t1) + 0.5 * self.width * sin_angle * np.cos(t1)
dy2 = 0.5 * self.height * cos_angle * np.sin(t2) + 0.5 * self.width * sin_angle * np.cos(t2)
if dy1 > dy2:
dy1, dy2 = dy2, dy1
xmin = self.center.x + dx1
xmax = self.center.x + dx2
ymin = self.center.y + dy1
ymax = self.center.y + dy2
return BoundingBox.from_float(xmin, xmax, ymin, ymax)