示例#1
0
    def test_point_height_above_plane(self):
        pl = plane.create([0., 1., 0.], 1.)
        p = np.array([0., 1., 0.])
        result = gt.point_height_above_plane(p, pl)
        self.assertEqual(result, 0.)

        p = np.array([0., 0., 0.])
        result = gt.point_height_above_plane(p, pl)
        self.assertEqual(result, -1.)

        v1 = np.array([ 0.0, 0.0, 1.0])
        v2 = np.array([ 1.0, 0.0, 1.0])
        v3 = np.array([ 0.0, 1.0, 1.0])
        p = np.array([0.0, 0.0, 20.0])

        pl = plane.create_from_points(v1, v2, v3)
        pl = plane.invert_normal(pl)

        result = gt.point_height_above_plane(p, pl)
        self.assertEqual(result, 19.)

        pl = plane.create_xz(distance=5.)
        p = np.array([0., 5., 0.])
        h = gt.point_height_above_plane(p, pl)
        self.assertEqual(h, 0.)
示例#2
0
        def test_x_y():
            vecs = numpy.array(
                [
                    [ 1.0, 0.0, 0.0 ],
                    [ 0.0, 1.0, 0.0 ],
                    [ 1.0, 1.0, 0.0 ]
                    ],
                dtype = numpy.float
                )
            result = plane.create_from_points(
                vecs[ 0 ],
                vecs[ 1 ],
                vecs[ 2 ]
                )
            expected_normal = numpy.array([ 0.0, 0.0, 1.0 ])
            expected_d = 0

            self.assertTrue(
                numpy.array_equal( result[ :3 ], expected_normal ),
                "Plane normal incorrect"
                )
            self.assertTrue(
                numpy.array_equal( result[ 3 ], expected_d ),
                "Plane distance incorrect"
                )
示例#3
0
    def test_create_from_points(self):
        result = plane.create_from_points(
            [1., 0., 0.],
            [0., 1., 0.],
            [1., 1., 0.],
        )
        self.assertTrue(np.allclose(result, [0., 0., 1., 0.]))
        self.assertTrue(np.allclose(plane.position(result), [0., 0., 0.]))

        result = plane.create_from_points(
            [1., 1., 0.],
            [1., 1., 1.],
            [0., 1., 1.],
        )
        expected = plane.create([0., 1., 0.], 1.)
        self.assertTrue(np.allclose(result, expected))
        self.assertTrue(np.allclose(plane.position(result), [0., 1., 0.]))
示例#4
0
文件: test_plane.py 项目: RazerM/Pyrr
 def test_create_from_points(self):
     vecs = np.array([
         [ 1.0, 0.0, 0.0 ],
         [ 0.0, 1.0, 0.0 ],
         [ 1.0, 1.0, 0.0 ]
     ])
     result = plane.create_from_points(*vecs)
     self.assertTrue(np.allclose(result, [0.,0.,1.,0.]))
示例#5
0
    def test_point_height_above_plane(self):
        v1 = np.array([ 0.0, 0.0, 1.0])
        v2 = np.array([ 1.0, 0.0, 1.0])
        v3 = np.array([ 0.0, 1.0, 1.0])
        p = np.array([0.0, 0.0, 20.0])

        pl = plane.create_from_points(v1, v2, v3)
        pl = plane.invert_normal(pl)

        result = gt.point_height_above_plane(p, pl)
        self.assertEqual(result, 19.)
示例#6
0
    def test_point_height_above_plane(self):
        v1 = np.array([ 0.0, 0.0, 1.0])
        v2 = np.array([ 1.0, 0.0, 1.0])
        v3 = np.array([ 0.0, 1.0, 1.0])
        p = np.array([0.0, 0.0, 20.0])

        pl = plane.create_from_points(v1, v2, v3)
        pl = plane.invert_normal(pl)

        result = gt.point_height_above_plane(p, pl)
        self.assertEqual(result, 19.)
示例#7
0
    def test_height_above_plane( self ):
        v1 = numpy.array( [ 0.0, 0.0, 1.0 ] )
        v2 = numpy.array( [ 1.0, 0.0, 1.0 ] )
        v3 = numpy.array( [ 0.0, 1.0, 1.0 ] )
        point = numpy.array([ 0.0, 0.0, 20.0 ])

        p = plane.create_from_points( v1, v2, v3 )
        p = plane.invert_normal( p )

        result = gt.point_height_above_plane( point, p )

        # should be 19.0
        expected = 19.0

        self.assertEqual(
            result,
            expected,
            "Height above plane incorrect"
            )
示例#8
0
 def test_create_from_points(self):
     vecs = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [1.0, 1.0, 0.0]])
     result = plane.create_from_points(*vecs)
     self.assertTrue(np.allclose(result, [0., 0., 1., 0.]))