Coverage for /opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/hypervehicle/components/polygon.py: 50%
24 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-29 02:51 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-29 02:51 +0000
1from hypervehicle.components import Component
2from hypervehicle.components.constants import CUBE, SPHERE
3from hypervehicle.geometry.vector import Vector3
4from hypervehicle.geometry.geometry import CubePatch, SpherePatch
7class Cube(Component):
8 componenttype = CUBE
10 def __init__(
11 self,
12 a: float,
13 centre: Vector3 = Vector3(0, 0, 0),
14 stl_resolution: int = 2,
15 verbosity: int = 1,
16 name: str = None,
17 ) -> None:
18 """
19 Parameters
20 -----------
21 a : float
22 The cube side half-length.
24 centre : Vector3, optional
25 The centre point of the cube. The default is Vector3(0,0,0).
26 """
27 self.a = a
28 self.centre = centre
29 super().__init__(stl_resolution=stl_resolution, verbosity=verbosity, name=name)
31 def generate_patches(self):
32 faces = ["east", "west", "south", "north", "bottom", "top"]
33 for face in faces:
34 self.patches[face] = CubePatch(self.a, self.centre, face)
37class Sphere(Component):
38 componenttype = SPHERE
40 def __init__(
41 self,
42 r: float,
43 centre: Vector3 = Vector3(0, 0, 0),
44 stl_resolution: int = 2,
45 verbosity: int = 1,
46 name: str = None,
47 ) -> None:
48 """
49 Parameters
50 -----------
51 r : float
52 The radius of the sphere.
54 centre : Vector3
55 The centre point of the sphere. The default is Vector3(0,0,0).
56 """
57 self.r = r
58 self.centre = centre
59 super().__init__(stl_resolution=stl_resolution, verbosity=verbosity, name=name)
61 def generate_patches(self):
62 faces = ["east", "west", "south", "north", "bottom", "top"]
64 for face in faces:
65 self.patches[face] = SpherePatch(self.r, self.centre, face)