hermann on Thu, 18 Jul 2024 22:24:25 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: New cgal4gp repo — Make CGAL functionality available for PARI/GP.


On 2024-07-13 23:11, hermann@stamm-wilbrandt.de wrote:
I started with that code, eliminated stuff I did not need, changed to use g++
instead of gcc because of CGAL, and have vertical prototype now:
https://github.com/Hermann-SW/cgal4gp

So nice, I will provide more functionality, but it works already:
...

I had completed all 7 CGAL Width_3 related functions for PARI/GP and thought I was done:
hermann@7600x:~/cgal4gp$ cat cgal4gp.gp
\\ https://doc.cgal.org/latest/Polytope_distance_d/classCGAL_1_1Width__3.html
\\
install("Width", "vG", "CGAL_Width", "./libcgal4gp.so");

install("get_squared_width", "v&&", "CGAL_get_squared_width", "./libcgal4gp.so"); install("get_width_planes", "v&&", "CGAL_get_width_planes", "./libcgal4gp.so"); install("get_width_coefficients", "v&&&&&", "CGAL_get_width_coefficients", "./libcgal4gp.so"); install("get_build_direction", "m", "CGAL_get_build_direction", "./libcgal4gp.so"); install("get_all_build_directions", "v&", "CGAL_get_all_build_directions", "./libcgal4gp.so"); install("get_number_of_optimal_solutions", "i", "CGAL_get_number_of_optimal_solutions", "./libcgal4gp.so");
hermann@7600x:~/cgal4gp$

This is from my application I did all that for:
hermann@7600x:~/cgal4gp$ tail tqf_width.gp  | head -8
        print("#S=",#S);
        CGAL_Width(S);
        CGAL_get_squared_width(num,denom);
        print("squared width: ",num/denom," [",num,"/",denom,"]");
        print("build direction: ",CGAL_get_build_direction());
print("optimal solutions: ",CGAL_get_number_of_optimal_solutions());
        CGAL_get_all_build_directions(dir);
print("workaround(all build directions): ", Set([d/gcd(d)*if(d[1]<0,-1,1) | d<-dir]));
hermann@7600x:~/cgal4gp$


Then 2 days ago I learned about CGAL Qt based Basic Viewer (2D and 3D), with interaction. I know that GP can draw functions, but am not sure whether it has 3D output.
So I tried to get CGAL Basic Viewer running from GP.
Just succeeded, I have working vertical prototype — dirty, not nice, lots of todos, but working !

This is possible now from GP:

pi@raspberrypi5:~/qh $ gp -q BVcgal4.gp
? points=[[1, 0, 0], [2, -1, 0], [2, 0, -1], [3, 0, 0], [2, 1, 0], [2, 0, 1]];
? CGAL_convex_hull_3(points)
[6, 12, 24, 8]
? CGAL_draw()
Using OpenGL context 4.5 GL


I recorded an animated .gif demonstrating all, find it in this posting:
https://forums.raspberrypi.com/viewtopic.php?p=2237908#p2237908


You can get some ideas of what becomes possible for GP on CGAL homepage:
https://www.cgal.org/


Regards,

Hermann.