How to use Payton - 10 common examples

To help you get started, we’ve selected a few Payton examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sinanislekdemir / payton / payton / scene / test_geometry.py View on Github external
def test_mesh_collision(self):
        a = Cube()
        b = Cube(width=2.0, height=1.23, depth=1.0)
        b.position = [1.0, 0.2, 0.1]
        c = CollisionTest(callback=dummy, objects=[a, b])
        check = c._mesh_collision(a, b)
        self.assertTrue(check)
github sinanislekdemir / payton / payton / scene / test_geometry.py View on Github external
def test_bounding_sphere_collision_false(self):
        a = Sphere(radius=2.0)
        b = Sphere()
        b.position = [4.5, 0.5, 0]
        c = CollisionTest(callback=dummy, objects=[a, b])
        check = c._bounding_sphere_collision(a, b)
        self.assertFalse(check)
github sinanislekdemir / payton / payton / scene / test_geometry.py View on Github external
def test_dist(self):
        a = Sphere()
        b = Sphere()
        b.position = [3, 0, 4]
        c = CollisionTest(callback=dummy, objects=[a, b])
        dist = c._dist(a, b)
        self.assertAlmostEqual(dist, 5)
github sinanislekdemir / payton / payton / scene / test_geometry.py View on Github external
def test_dist(self):
        a = Sphere()
        b = Sphere()
        b.position = [3, 0, 4]
        c = CollisionTest(callback=dummy, objects=[a, b])
        dist = c._dist(a, b)
        self.assertAlmostEqual(dist, 5)
github sinanislekdemir / payton / payton / scene / test_geometry.py View on Github external
def test_sphere_in_sphere_false(self):
        a = Sphere(radius=10)
        b = Sphere(radius=2)
        b.position = [10, 2, 0]
        c = CollisionTest(callback=dummy, objects=[a, b])
        check = c._sphere_in_sphere_collision(a, b)
        self.assertFalse(check)
github sinanislekdemir / payton / payton / scene / test_geometry.py View on Github external
def test_mesh_collision(self):
        a = Cube()
        b = Cube(width=2.0, height=1.23, depth=1.0)
        b.position = [1.0, 0.2, 0.1]
        c = CollisionTest(callback=dummy, objects=[a, b])
        check = c._mesh_collision(a, b)
        self.assertTrue(check)
github sinanislekdemir / payton / payton / scene / test_geometry.py View on Github external
def test_sphere_in_sphere_false(self):
        a = Sphere(radius=10)
        b = Sphere(radius=2)
        b.position = [10, 2, 0]
        c = CollisionTest(callback=dummy, objects=[a, b])
        check = c._sphere_in_sphere_collision(a, b)
        self.assertFalse(check)
github sinanislekdemir / payton / payton / scene / test_geometry.py View on Github external
def test_sphere_in_sphere(self):
        a = Sphere(radius=10)
        b = Sphere(radius=2)
        b.position = [2, 2, 0]
        c = CollisionTest(callback=dummy, objects=[a, b])
        check = c._sphere_in_sphere_collision(a, b)
        self.assertTrue(check)
github sinanislekdemir / payton / payton / math / test_geometry.py View on Github external
def test_distance(self):
        p1 = np.array([2, 5, 3], dtype=np.float32)
        p2 = np.array([3, 9, -2], dtype=np.float32)
        d = distance(p1, p2)
        self.assertAlmostEqual(d, 6.4807405)
github sinanislekdemir / payton / examples / basics / 30_near_far_plane.py View on Github external
direction = 0


scene.active_observer.far = 20
collision = CollisionTest(callback=hit)
for i in range(50):
    x = random.randint(-5, 5)
    y = random.randint(-5, 5)
    z = random.randint(-5, 5)
    if i % 2 == 0:
        s = Sphere()
        s.position = [x, y, z]
        scene.add_object("s_{}".format(i), s)
        collision.add_object(s)
    else:
        c = Cube()
        c.position = [x, y, z]
        scene.add_object("c_{}".format(i), c)
        collision.add_object(c)

scene.add_collision_test("test", collision)
scene.create_clock("plane", 0.01, change_near_plane)
scene.run()