예제 #1
0
 def test_draw_points(self):
     from clifford.tools.g3 import random_euc_mv
     from clifford.g3 import layout
     gs = GanjaScene()
     gs.add_objects([random_euc_mv().value[0:8] for i in range(10)], static=False)
     with open('test_file.html', 'w') as test_file:
         print(generate_full_html(str(gs), sig=layout.sig, grid=True, scale=1.0, gl=False), file=test_file)
     render_cef_script(str(gs), sig=layout.sig, grid=True, scale=1.0, gl=False)
예제 #2
0
 def test_draw_points(self):
     gs = GanjaScene()
     gs.add_objects([self.random_point() for i in range(10)], static=False)
     with open('test_file.html', 'w') as test_file:
         test_file.write(
             generate_full_html(str(gs),
                                sig=self.layout.sig,
                                grid=True,
                                scale=1.0,
                                gl=True))
     draw(gs, sig=self.layout.sig, grid=True, scale=1.0, gl=True)
예제 #3
0
 def test_scene_addition(self):
     from clifford.tools.g3c import random_line, random_circle
     a = GanjaScene()
     a.add_objects([random_line() for i in range(10)], color=Color.RED)
     b = GanjaScene()
     b.add_objects([random_circle() for i in range(10)], color=Color.BLUE)
     draw(a + b, scale=0.01)
예제 #4
0
 def test_pyganja_facet(self):
     from clifford.tools.g3c import random_conformal_point
     from pyganja import GanjaScene
     gs = GanjaScene()
     point_list = [random_conformal_point() for i in range(3)]
     #gs.add_objects(point_list)
     gs.add_facet(point_list)
     point_list = [random_conformal_point() for i in range(3)]
     #gs.add_objects(point_list)
     #gs.add_facet(point_list,color=int('AAFF0000',16))
     facet_list = [[random_conformal_point() for i in range(3)] for i in range(10)]
     #gs.add_facets(facet_list,color=int('AA0000FF',16))
     draw(gs, scale=0.05, browser_window=True)
     print(gs)
예제 #5
0
    def test_eval_final_poly_circles(self):
        from scene_objects import CircleSurface
        X0 = random_circle()
        X1 = random_circle()
        S = average_objects([X1, X0], [0.2, (1 - 0.2)])
        L = ((S * einf * S) ^ up(0.0) ^ einf).normal()

        Xdash = MultiVectorPolynomial(cf.MVArray([X0, X1 - X0]))
        full_poly = gen_full_poly_circles(Xdash, L)
        print('full_poly ', full_poly)
        print('', flush=True)
        final_scalar_poly = gen_full_scalar_poly_circles(Xdash, L)
        jitted_scalar_poly = jitted_gen_full_scalar_poly_circles(
            cf.MVArray([X0, X1 - X0]), L)

        from pyganja import GanjaScene, Color
        gs = GanjaScene()
        gs.add_objects([X0, X1], color=Color.BLACK)
        gs.add_objects([S], color=Color.RED)
        gs.add_objects([L])
        draw(gs, scale=0.1)

        r = potential_roots_circles(X0, X1, L)

        surf = CircleSurface(X0, X1, nprobe_alphas=2000)
        print('probe method: ', surf.intersection_func(L.value))
        print('\n\n\n')
        print('polynomial method: ', r)
        print(len(surf.probe_alphas), flush=True)
        time.sleep(0.5)

        # for alpha in surf.probe_alphas:
        #     print(full_poly(alpha))

        # test the value at each
        import matplotlib.pyplot as plt
        plt.figure()
        plt.plot(surf.probe_alphas, surf.probe_func(L.value))
        plt.plot(surf.probe_alphas,
                 [final_scalar_poly(alpha) for alpha in surf.probe_alphas],
                 'r')
        plt.plot(surf.probe_alphas,
                 [jitted_scalar_poly(alpha) for alpha in surf.probe_alphas],
                 'g')
        plt.plot(surf.probe_alphas, surf.probe_alphas * 0, 'k')
        plt.legend(["true meet", "polynomial function", "zero"])
        plt.savefig('circle_root_func.png')
        plt.show()
예제 #6
0
 def test_print_scene(self):
     from clifford.tools.g3c import random_line
     gs = GanjaScene()
     gs.add_objects([random_line() for i in range(2)])
     print(gs)