def test_position(self): p = plane.create_xz(distance=-5.) result = plane.position(p) self.assertTrue(np.allclose(result, [0., -5., 0.])) p = plane.create_from_position(position=[0., 0., 1.], normal=[0., 0., 1.]) self.assertTrue(np.allclose(plane.position(p), [0., 0., 1.]))
def _surface_plane(self) -> Plane: """ Return the surface plane of the plate """ plate_surface = np.array([ self.plate.x, self.plate.y, self.plate.z + PLATE_ORIGIN_TO_SURFACE_OFFSET ]) return create_from_position(plate_surface, self._plate_nor())
def __init__( self, position, normal, up, size = (1.0, 1.0) ): super( Planar, self ).__init__() self.plane = plane.create_from_position( position, normal, up ) self.size = size
def test_create_from_position(self): position = np.array([1.0, 0.0, 0.0]) normal = np.array([0.0, 3.0, 0.0]) result = plane.create_from_position(position, normal) self.assertTrue(np.allclose(result, [0., 1., 0., 0.])) p0 = position + [1., 0., 0.] p = position n = vector.normalise(normal) coplanar = p - p0 self.assertEqual(np.sum(n * coplanar), 0.)
def test_create_from_position( self ): position = numpy.array( [ 1.0, 0.0, 0.0 ] ) normal = numpy.array( [ 0.0, 3.0, 0.0 ] ) result = plane.create_from_position( position, normal ) expected_normal = numpy.array([0.0, 1.0, 0.0] ) expected_position = numpy.array([0.0, 0.0, 0.0] ) self.assertTrue( numpy.array_equal( result[ :3 ], expected_normal ), "Plane normal incorrect" ) self.assertTrue( numpy.array_equal( plane.position(result), expected_position ), "Plane position incorrect" )
def test_create_from_position(self): position = np.array([1.0, 0.0, 0.0]) normal = np.array([0.0, 3.0, 0.0]) result = plane.create_from_position(position, normal) self.assertTrue(np.allclose(result, [0., 1., 0., 0.]))
def __init__(self, position, normal, up, size=(1.0, 1.0)): super(Planar, self).__init__() self.plane = plane.create_from_position(position, normal, up) self.size = size