Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def CalculateHexagonParameters(self):
mmin = trinity.TriVector(-1.0, 0.0, -0.866025447845459)
mmax = trinity.TriVector(1.0, 0.0, 0.866025447845459)
maxx = mmax.z / math.sin(math.radians(60.0))
topRightX = math.cos(math.radians(60.0)) * maxx
self.tileMin = Point(-maxx, mmin.z)
self.tileMax = Point(maxx, mmax.z)
self.hexPoints = (Point(topRightX, self.tileMax.y),
Point(self.tileMax.x, 0.0),
Point(topRightX, self.tileMin.y),
Point(-topRightX, self.tileMin.y),
Point(self.tileMin.x, 0.0),
Point(-topRightX, self.tileMax.y))
self.tileWidth = maxx * 2.0 * 0.75
self.tileHeight = mmax.z * 2.0
if in_nw and in_ne and in_se and in_sw:
self.items.append(item)
else:
if in_nw:
nw_items.append(item)
if in_ne:
ne_items.append(item)
if in_se:
se_items.append(item)
if in_sw:
sw_items.append(item)
if nw_items:
self.nw = QuadTree(nw_items, depth, AABB(Point(aabb.min.x, aabb.min.y), Point(center.x, center.y)))
if ne_items:
self.ne = QuadTree(ne_items, depth, AABB(Point(center.x, aabb.min.y), Point(aabb.max.x, center.y)))
if se_items:
self.se = QuadTree(se_items, depth, AABB(Point(center.x, center.y), Point(aabb.max.x, aabb.max.y)))
if sw_items:
self.sw = QuadTree(sw_items, depth, AABB(Point(aabb.min.x, center.y), Point(center.x, aabb.max.y)))
def GetAdaptedHexPoints(self, tile):
newPoints = []
pos = Point(tile.center[0], tile.center[2])
for point in self.hexPoints:
newPoint = point * tile.scale + pos
newPoints.append(newPoint)
return newPoints
def CalculateHexagonParameters(self):
mmin = trinity.TriVector(-1.0, 0.0, -0.866025447845459)
mmax = trinity.TriVector(1.0, 0.0, 0.866025447845459)
maxx = mmax.z / math.sin(math.radians(60.0))
topRightX = math.cos(math.radians(60.0)) * maxx
self.tileMin = Point(-maxx, mmin.z)
self.tileMax = Point(maxx, mmax.z)
self.hexPoints = (Point(topRightX, self.tileMax.y),
Point(self.tileMax.x, 0.0),
Point(topRightX, self.tileMin.y),
Point(-topRightX, self.tileMin.y),
Point(self.tileMin.x, 0.0),
Point(-topRightX, self.tileMax.y))
self.tileWidth = maxx * 2.0 * 0.75
self.tileHeight = mmax.z * 2.0
nw_items.append(item)
if in_ne:
ne_items.append(item)
if in_se:
se_items.append(item)
if in_sw:
sw_items.append(item)
if nw_items:
self.nw = QuadTree(nw_items, depth, AABB(Point(aabb.min.x, aabb.min.y), Point(center.x, center.y)))
if ne_items:
self.ne = QuadTree(ne_items, depth, AABB(Point(center.x, aabb.min.y), Point(aabb.max.x, center.y)))
if se_items:
self.se = QuadTree(se_items, depth, AABB(Point(center.x, center.y), Point(aabb.max.x, aabb.max.y)))
if sw_items:
self.sw = QuadTree(sw_items, depth, AABB(Point(aabb.min.x, center.y), Point(center.x, aabb.max.y)))
def CalculateHexagonParameters(self):
mmin = trinity.TriVector(-1.0, 0.0, -0.866025447845459)
mmax = trinity.TriVector(1.0, 0.0, 0.866025447845459)
maxx = mmax.z / math.sin(math.radians(60.0))
topRightX = math.cos(math.radians(60.0)) * maxx
self.tileMin = Point(-maxx, mmin.z)
self.tileMax = Point(maxx, mmax.z)
self.hexPoints = (Point(topRightX, self.tileMax.y),
Point(self.tileMax.x, 0.0),
Point(topRightX, self.tileMin.y),
Point(-topRightX, self.tileMin.y),
Point(self.tileMin.x, 0.0),
Point(-topRightX, self.tileMax.y))
self.tileWidth = maxx * 2.0 * 0.75
self.tileHeight = mmax.z * 2.0
in_ne = item.max.x >= center.x and item.min.y <= center.y
in_se = item.max.x >= center.x and item.max.y >= center.y
if in_nw and in_ne and in_se and in_sw:
self.items.append(item)
else:
if in_nw:
nw_items.append(item)
if in_ne:
ne_items.append(item)
if in_se:
se_items.append(item)
if in_sw:
sw_items.append(item)
if nw_items:
self.nw = QuadTree(nw_items, depth, AABB(Point(aabb.min.x, aabb.min.y), Point(center.x, center.y)))
if ne_items:
self.ne = QuadTree(ne_items, depth, AABB(Point(center.x, aabb.min.y), Point(aabb.max.x, center.y)))
if se_items:
self.se = QuadTree(se_items, depth, AABB(Point(center.x, center.y), Point(aabb.max.x, aabb.max.y)))
if sw_items:
self.sw = QuadTree(sw_items, depth, AABB(Point(aabb.min.x, center.y), Point(center.x, aabb.max.y)))
def CalculateHexagonParameters(self):
mmin = trinity.TriVector(-1.0, 0.0, -0.866025447845459)
mmax = trinity.TriVector(1.0, 0.0, 0.866025447845459)
maxx = mmax.z / math.sin(math.radians(60.0))
topRightX = math.cos(math.radians(60.0)) * maxx
self.tileMin = Point(-maxx, mmin.z)
self.tileMax = Point(maxx, mmax.z)
self.hexPoints = (Point(topRightX, self.tileMax.y),
Point(self.tileMax.x, 0.0),
Point(topRightX, self.tileMin.y),
Point(-topRightX, self.tileMin.y),
Point(self.tileMin.x, 0.0),
Point(-topRightX, self.tileMax.y))
self.tileWidth = maxx * 2.0 * 0.75
self.tileHeight = mmax.z * 2.0
def GetAdaptedTileAABB(self, tile):
v = Point(tile.center[0], tile.center[2])
return AABB(self.tileMin * tile.scale + v, self.tileMax * tile.scale + v)