Example #1
0
            test = raw_input(
                'Enter index of the algorithm for which you want to visualize the plane : '
            )
            if test != '':
                try:
                    ialgo = int(test)
                    algo = cg.algorithms[ialgo]
                    sepplane = True
                except:
                    print(
                        'Unable to determine the algorithm/separation_plane you want '
                        'to visualize for this geometry. Continues without ...'
                    )
        myfactor = 3.0
        if vis is None:
            vis = visualize(cg=cg, zoom=1.0, myfactor=myfactor)
        else:
            vis = visualize(cg=cg, vis=vis, myfactor=myfactor)
        cg_points = [myfactor * np.array(pp) for pp in cg.points]
        cg_central_site = myfactor * np.array(cg.central_site)
        if sepplane:
            pts = [cg_points[ii] for ii in algo.plane_points]
            if algo.minimum_number_of_points == 2:
                pts.append(cg_central_site)
                centre = cg_central_site
            else:
                centre = np.sum(pts, axis=0) / len(pts)

            factor = 1.5
            target_dist = max(
                [np.dot(pp - centre, pp - centre) for pp in cg_points])
Example #2
0
            print('')
        # Visualize the separation plane of a given algorithm
        sepplane = False
        if any([algo.algorithm_type == SEPARATION_PLANE for algo in cg.algorithms]):
            test = input('Enter index of the algorithm for which you want to visualize the plane : ')
            if test != '':
                try:
                    ialgo = int(test)
                    algo = cg.algorithms[ialgo]
                    sepplane = True
                except:
                    print('Unable to determine the algorithm/separation_plane you want '
                          'to visualize for this geometry. Continues without ...')
        myfactor = 3.0
        if vis is None:
            vis = visualize(cg=cg, zoom=1.0, myfactor=myfactor)
        else:
            vis = visualize(cg=cg, vis=vis, myfactor=myfactor)
        cg_points = [myfactor*np.array(pp) for pp in cg.points]
        cg_central_site = myfactor*np.array(cg.central_site)
        if sepplane:
            pts = [cg_points[ii] for ii in algo.plane_points]
            if algo.minimum_number_of_points == 2:
                pts.append(cg_central_site)
                centre = cg_central_site
            else:
                centre = np.sum(pts, axis=0) / len(pts)

            factor = 1.5
            target_dist = max([np.dot(pp-centre, pp-centre) for pp in cg_points])
            current_dist = np.dot(pts[0] - centre, pts[0] - centre)