def test_eq(self) -> None: self.assertEqual( sphere.Sphere(diameter=15.0), sphere.Sphere(diameter=15.0), msg="Equivalent cylinders should be equal", ) self.assertNotEqual( sphere.Sphere(diameter=15.0), sphere.Sphere(diameter=20.0), msg="Equivalent cylinders should be equal", )
def test_center_anchor_position(self) -> None: self.assertEqual( sphere.Sphere(diameter=20.0).center_anchor, connector.Connector(), msg="Center connector should be positioned as expected", ) self.assertEqual( sphere.Sphere(diameter=20.0).transform( solid.utils.up(10.0)).center_anchor, connector.Connector.from_components(point_z=10.0), msg="Center connector should move with translation", )
def test_copy(self) -> None: test_sphere = sphere.Sphere(diameter=15.0) copy_sphere = test_sphere.copy() self.assertEqual( test_sphere, copy_sphere, msg="Copied spheres should be equivalent to the originals", )
def __init__(self, parent: component.Component = None) -> None: """ Args: parent: The frame's parent, if any; this component will be set as one of the parent's children """ # A central sphere corresponding to the connector's location self.origin = sphere.Sphere(diameter=1.0) # Three arms representing the connector's orientation self.x_arm = self._arm(axis=vector.AXIS_X, color=(1.0, 0.0, 0.0)) self.y_arm = self._arm(axis=vector.AXIS_Y, color=(0.0, 1.0, 0.0)) self.z_arm = self._arm(axis=vector.AXIS_Z, color=(0.0, 0.0, 1.0)) # need to get this to work without making them children, because # otherwise copying doesn't work, i think super().__init__( parent=parent, children=[self.origin, self.x_arm, self.y_arm, self.z_arm])
def test_radius(self) -> None: self.assertEqual( sphere.Sphere(diameter=20.0).radius, 10.0, msg="Radius should be as expected", )
def test_body(self) -> None: self.assertTrue( utils.compare_openscad_objects( sphere.Sphere(diameter=15.0).body, solid.sphere(d=15.0)), msg="Should produce the expected OpenSCAD object", )