def get_plotting_vtx(vertex_lst): leftmost, rightmost, top, bottom = Point_2(), Point_2(), Point_2( ), Point_2() CGAL_Convex_hull_2.ch_n_point(vertex_lst, top) # maximal y coordinate. CGAL_Convex_hull_2.ch_e_point(vertex_lst, rightmost) # maximal x coordinate. CGAL_Convex_hull_2.ch_s_point(vertex_lst, bottom) # minimal y coordinates CGAL_Convex_hull_2.ch_w_point(vertex_lst, leftmost) # minimal x coordinate lt, rt = leftmost.x(), rightmost.x() tp, btm = top.y(), bottom.y() draw_pt_list = [] for pair in product([lt, rt], [tp, btm]): draw_pt_list.append(pair) # left_btm_x, left_btm_y= draw_pt_list[1] delta_x = (lt + rt) / 2 - 0 delta_y = (tp + btm) / 2 - 0 ch_height = tp - btm ch_width = rt - lt return ch_height, ch_width, delta_x, delta_y
def convex_hull_2d(): """Convex hull for two dimensions """ points = [] points.append(kernel.Point_2(0, 0)) points.append(kernel.Point_2(1, 0)) points.append(kernel.Point_2(0, 1)) points.append(kernel.Point_2(1, 1,)) points.append(kernel.Point_2(0.5, 0.5)) points.append(kernel.Point_2(0.25, 0.25)) result = [] CGAL_Convex_hull_2.convex_hull_2(points, result) for p in result: print(p) points.append(kernel.Point_2(2, 2)) n = kernel.Point_2() CGAL_Convex_hull_2.ch_n_point(points, n) print(n)
from __future__ import print_function from CGAL.CGAL_Kernel import Point_2 from CGAL import CGAL_Convex_hull_2 L = [] L.append(Point_2(0, 0)) L.append(Point_2(1, 0)) L.append(Point_2(0, 1)) L.append(Point_2(1, 1)) L.append(Point_2(0.5, 0.5)) L.append(Point_2(0.25, 0.25)) result = [] CGAL_Convex_hull_2.convex_hull_2(L, result) for p in result: print(p) L.append(Point_2(2, 2)) n = Point_2() CGAL_Convex_hull_2.ch_n_point(L, n) print(n)
from __future__ import print_function from CGAL.CGAL_Kernel import Point_2 from CGAL import CGAL_Convex_hull_2 L=[] L.append( Point_2(0,0) ) L.append( Point_2(1,0) ) L.append( Point_2(0,1) ) L.append( Point_2(1,1) ) L.append( Point_2(0.5,0.5) ) L.append( Point_2(0.25,0.25) ) result = [] CGAL_Convex_hull_2.convex_hull_2(L, result) for p in result: print(p) L.append( Point_2(2,2) ) n=Point_2() CGAL_Convex_hull_2.ch_n_point(L,n) print(n)