def big_triangle(cls): body = Polygon( [Point3D(-3, 0, 0), Point3D(3, -3, 0), Point3D(3, 3, 0)]) return PolygonComponent(body), HitboxComponent( body, is_collision_source=True)
def basic_triangle(cls): body = Polygon( [Point3D(-1, 0, 0), Point3D(1, -1, 0), Point3D(1, 1, 0)]) return PolygonComponent(body), HitboxComponent( body, is_collision_source=True)
def triangle(side, rotation=None): height = (side / 2) * 0.86 return PrimitiveShapes._transform_and_return( Polygon([ Point3D(0, height * 0.5, 0), Point3D(-side * 0.5, -height * 0.5, 0), Point3D(side * 0.5, -height * 0.5, 0), ]), rotation)
def rectangle(width, height, rotation=None): return PrimitiveShapes._transform_and_return( Polygon([ Point3D(-width * 0.5, -height * 0.5, 0), Point3D(width * 0.5, -height * 0.5, 0), Point3D(width * 0.5, height * 0.5, 0), Point3D(-width * 0.5, height * 0.5, 0), ]), rotation)
def test_point_is_inside_polygon(self): point = Point3D(1, 1, 0) polygon = Polygon([ Point3D(0, 0, 0), Point3D(2, 0, 0), Point3D(2, 2, 0), Point3D(0, 2, 0) ]) assert GeometryOperations.is_point_inside_polygon(point, polygon)
def star4arms(outer_radius, inner_radius, rotation=None): return PrimitiveShapes._transform_and_return( Polygon([ Point3D(inner_radius, 0, 0), Point3D(outer_radius, outer_radius, 0), Point3D(0, inner_radius, 0), Point3D(-outer_radius, outer_radius, 0), Point3D(-inner_radius, 0, 0), Point3D(-outer_radius, -outer_radius, 0), Point3D(0, -inner_radius, 0), Point3D(outer_radius, -outer_radius, 0), ]), rotation)
def octogon(radius, rotation=None): return PrimitiveShapes._transform_and_return( Polygon([ Point3D(radius, 0, 0), Point3D(radius * 0.7, radius * 0.7, 0), Point3D(0, radius, 0), Point3D(-radius * 0.7, radius * 0.7, 0), Point3D(-radius, 0, 0), Point3D(-radius * 0.7, -radius * 0.7, 0), Point3D(0, -radius, 0), Point3D(radius * 0.7, -radius * 0.7, 0), ]), rotation)