Exemplo n.º 1
0
    def test_test1(self):
        b1 = Box([0, 0, 0], [1, 1, 1])
        b2 = Box([2, 0, 0], [3, 1, 1])

        result = b1.has_collisions(b2)

        self.assertEqual(result['collision'], False)
Exemplo n.º 2
0
    def test_test7(self):
        b1 = Box([0, 0, 0], [1, 1, 1])
        b2 = Box([0, 0, 0], [1, 1, 1])
        b2.translation = [1, 0, 0]
        b2.translation = [1e-4, 0, 0]

        result = b1.has_collisions(b2, verbose=True, atol=1e-5, item='value')

        self.assertEqual(result['collision'], False)
Exemplo n.º 3
0
    def test_test6(self):
        b1 = Box([0, 0, 0], [1, 1, 1])
        b2 = Box([0, 0, 0], [1, 1, 1])
        b2.translation = [1, 0, 0]
        b2.translation = [1e-4, 0, 0]

        result = b1.has_collisions(b2, atol=1e-4)

        self.assertEqual(result['collision'], True)
Exemplo n.º 4
0
    def test_test5(self):
        b1 = Box([0, 0, 0], [1, 1, 1])
        b2 = Box([0, 0, 0], [1, 1, 1])
        b2.translation = [1, 0, 0]

        result = b1.has_collisions(b2, verbose=True)

        self.assertEqual(result['collision'], True)
Exemplo n.º 5
0
    def test_test4(self):
        b1 = Box([0, -1, -1], [1, 2, 2])
        b2 = Box([0, 0, 0], [1, 1, 1])
        b2.translation = [1, 0, 0]

        result = b1.has_collisions(b2)

        self.assertEqual(result['collision'], True)
Exemplo n.º 6
0
    def test_test12(self):
        b1 = Box([-1, -1, -1], [1, 1, 1])

        self.assertEqual(b1.get_volume(), 8.)
Exemplo n.º 7
0
    def test_test11(self):
        with mock.patch('sys.stdout', new=io.StringIO()) as fake_stdout:
            b1 = Box([-1, -1, -1], [1, 1, 1], verbose=True)

        self.assertEqual(fake_stdout.getvalue(),
                         'DEBUG: reference volume: 8.0\n')
Exemplo n.º 8
0
    def test_test10(self):
        b1 = Box([-1, -1, -1], [1, 1, 1])

        self.assertEqual(b1._volume, 8.)
Exemplo n.º 9
0
    def test_test1(self):
        b1 = Box([1, 2, 3], [4, 5, 6])
        p = b1.position

        self.assertEqual(np.all(p[0] == np.array([1., 2., 3.])), True)
        self.assertEqual(np.all(p[1] == np.array([4., 5., 6.])), True)
Exemplo n.º 10
0
    def test_test100(self):
        b1 = Box([0, 0, 0], [1, 1, 1])
        i = 1  # int object

        with self.assertRaises(ValueError) as context:
            result = b1.has_collisions(i)
Exemplo n.º 11
0
    print(p1.distance)

    # plane / sphere
    s1 = Sphere([0, 0, 0], 1.)

    p1 = create_xy_plane(1)
    p1.translation = [1, 0, 0]

    result = s1.has_collisions(p1, verbose=True)

    print(result)
    # get the result
    print(result())

    # plane / plane

    p1 = create_xy_plane(0)
    p2 = create_xy_plane(1e-5)

    result = p1.has_collisions(p2, verbose=True, atol=1e-4)

    print(result)
    # get the result
    print(result())

    # plane / box
    b1 = Box([0, 0, 0], [1, 1, 1])
    p1 = create_yz_plane(0.5)

    reult = b1.has_collisions(p1, verbose=True)
Exemplo n.º 12
0
"""

from pycollision.objects import Box

from pycollision.rotation import *

import numpy as np

if __name__ == '__main__':

    # this setup is dynamically
    # two boxes with a distance of x=0.5 and box1
    # rotates at x=1 side around the z axis against
    # box2 like a falling domino ...
    b1 = Box([0, 0, 0], [1, 1, 1], verbose=True)

    # first translation as a preperation of the rotation
    b1.translation = [-1, 0, 0]

    # compensation of the 1st translation
    b1.post_translation = [1, 0, 0]



    b2 = Box([0,0,0], [1,1,1])
    b2.translation = [1.5,0,0]


    for i in range(90):
        print('%2i : %s' % (i, b1.has_collisions(b2, verbose=False, atol=1e-10)))