In [1]:
import sys,os,imp,re
import math
import numpy as np
import matplotlib as mpl

import matplotlib.cm as cm
import matplotlib.pyplot as plt

import matplotlib.colors as colors
import matplotlib.cm as cmx
from mpl_toolkits.mplot3d import Axes3D


mpl.rcParams['figure.figsize']=(6.0,4.0)    #(6.0,4.0)
mpl.rcParams['font.size']=10                #10 
mpl.rcParams['savefig.dpi']=400             #72 
mpl.rcParams['figure.subplot.bottom']=.1    #.125

plt.rc('font', family='serif')
plt.rc('text', usetex=True)

#inline Shit
%matplotlib inline
%config InlineBackend.figure_format='svg'
%config InlineBackend.rc = {'figure.facecolor': 'white', 'figure.subplot.bottom': 0.125, 'figure.edgecolor': 'white', 'savefig.dpi': 400, 'figure.figsize': (12.0, 8.0), 'font.size': 10}

#GUi shit
%matplotlib tk
mpl.get_configdir()


Out[1]:
'/home/zfmgpu/.config/matplotlib'

In [2]:
def plotCube(ax,minP = np.array([-1.0,-1.0,-1.0]), maxP=np.array([1.0,1.0,1.0]),
             trans= np.array([0.0,0.0,0.0]),rotationMatrix=np.diag([1,1,1])):
    from itertools import product, combinations
    r = [-1, 1]
    
    centerPos = (maxP + minP)/2.0;
    #print(centerPos)
    extent = (maxP - minP)/2.0;
    
    points = np.array([(-1, -1, -1),
                     (-1, -1, 1),
                     (-1, 1, -1),
                     (-1, 1, 1),
                     (1, -1, -1),
                     (1, -1, 1),
                     (1, 1, -1),
                     (1, 1, 1)]);
    
    for s, e in combinations(points, 2):
        if np.sum(np.abs(s-e)) == r[1]-r[0]: # no diagonal lines
            p1 = np.array(s,dtype=float); p2 = np.array(e,dtype=float);
            #scale points
            p1*=extent; p2*=extent;
            #rotate and translate points
            p1 = rotationMatrix.dot(p1 + centerPos) + trans;
            p2 = rotationMatrix.dot(p2+centerPos) + trans;
            ax.plot3D(*zip(p1,p2), color="b")

def plotAxis(ax,centerPos,A_IK,plotAxisScale=1):
        for i,c in zip([0,1,2],['r','g','b']):
            I_eK_i = A_IK[:,i];
            lines = list(zip(centerPos,plotAxisScale*I_eK_i+centerPos))
            v = Arrow3D(*lines, mutation_scale=50, lw=1, arrowstyle="-|>", color=c);
            ax.plot3D(*lines, color=c)
            ax.add_artist(v);

def plotAxis2d(ax,centerPos,u,v,plotAxisScale=1):
    
    x = np.vstack((centerPos,plotAxisScale*u+centerPos))
    y = np.vstack((centerPos,plotAxisScale*v+centerPos))
    ax.plot(x.T[0],x.T[1],'r',lw=2)
    ax.plot(y.T[0],y.T[1],'b',lw=2)
        
            
from matplotlib.patches import FancyArrowPatch
from mpl_toolkits.mplot3d import proj3d
class Arrow3D(FancyArrowPatch):
        def __init__(self, xs, ys, zs, *args, **kwargs):
            FancyArrowPatch.__init__(self, (0,0), (0,0), *args, **kwargs)
            self._verts3d = xs, ys, zs
     
        def draw(self, renderer):
            xs3d, ys3d, zs3d = self._verts3d
            xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
            self.set_positions((xs[0],ys[0]),(xs[1],ys[1]))
            FancyArrowPatch.draw(self, renderer)

In [3]:
def axisEqual3D(ax):
    extents = np.array([getattr(ax, 'get_{}lim'.format(dim))() for dim in 'xyz'])
    sz = extents[:,1] - extents[:,0]
    centers = np.mean(extents, axis=1)
    maxsize = max(abs(sz))
    r = maxsize/2
    for ctr, dim in zip(centers, 'xyz'):
        getattr(ax, 'set_{}lim'.format(dim))(ctr - r, ctr + r)

In [4]:
# get all files
def loadFiles(folderPath,filePathRegex, keyNames):
    files = [ os.path.join(folderPath,f) for f in os.listdir(folderPath) if os.path.isfile( os.path.join(folderPath,f) ) ]

    filePaths=dict();
    for f in files:
        res = re.match(filePathRegex,f)
        if(res):
            key = res.group(1)
            filePaths[key]= dict( [ (keyN, g) for keyN,g in zip(keyNames,res.groups()) ] )
            filePaths[key]["path"] = f
    return filePaths;

In [5]:
import struct
def readPointsMatrixBinary(filePath):
    f = open(filePath, "br")
    # read header (rows,columns)
    (bigEndian,) = struct.unpack("?",f.read(1));
    formatStringBO = "<"; # little endian
    dtype = np.dtype("<f8")
    if(bigEndian):
        formatStringBO = ">";
        dtype = np.dtype(">f8")
    
    (rows,cols,nbytes) = struct.unpack("%sQQQ" % formatStringBO ,  f.read(3*np.int64(0).nbytes))
    print("Matrix Binary: " , rows,cols,nbytes, "big Endian:", bigEndian)                           
    return np.fromfile(f,dtype=dtype);

Convex Hull Tests


In [8]:
plt.close("all")

files = loadFiles("./" , ".*ConvexHullTest-(.*?)-(\w+)\.bin", ("name","prec") );
filesOut = loadFiles("./" , ".*ConvexHullTest-(.*?)-(\w+)-Out\.bin", ("name","prec"));

for i,f in files.items():
    
    fOut = filesOut[i]; print(i,f,fOut)
    fig = plt.figure("ConvexHullTest"+str(i),(10,10))
    
    if(i!="PointsRandom14M"):
        points = readPointsMatrixBinary(f["path"]); points=np.reshape(points,(-1,2)) 
        
    hullP =  readPointsMatrixBinary(fOut["path"]); hullP=np.reshape(hullP,(-1,2))
    hullP = np.vstack((hullP,hullP[0]))
    
    plt.plot(hullP.T[0],hullP.T[1],'b-o', ms=20, markerfacecolor='None')
    
    if(i!="PointsRandom14M"):
        plt.scatter(points.T[0],points.T[1],c='r')
        if(len(points)<300):
            nrRange = [(i,p[0],p[1])  for i,p in enumerate(points) ]
            for x in nrRange:      
                plt.annotate('%s' % x[0], xy=x[1:3], textcoords='offset points') # <--
    
#     if(len(hullP)<300):
#         nrRange = [(i,p[0],p[1])  for i,p in enumerate(hullP) ]
#         for x in nrRange:      
#             plt.annotate('%s' % x[0], xy=x[1:3], textcoords='offset points') # <--


PointsBadProjection4 {'name': 'PointsBadProjection4', 'prec': 'double', 'path': './ConvexHullTest-PointsBadProjection4-double.bin'} {'name': 'PointsBadProjection4', 'prec': 'double', 'path': './ConvexHullTest-PointsBadProjection4-double-Out.bin'}
Matrix Binary:  2 16 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
Triangle {'name': 'Triangle', 'prec': 'double', 'path': './ConvexHullTest-Triangle-double.bin'} {'name': 'Triangle', 'prec': 'double', 'path': './ConvexHullTest-Triangle-double-Out.bin'}
/opt/python3.4Env/lib/python3.4/site-packages/matplotlib/text.py:2130: UserWarning: You have used the `textcoords` kwarg, but not the `xytext` kwarg.  This can lead to surprising results.
  warnings.warn("You have used the `textcoords` kwarg, but not "
Matrix Binary:  2 3 8 big Endian: False
Matrix Binary:  2 3 8 big Endian: False
PointsOnCricle1000 {'name': 'PointsOnCricle1000', 'prec': 'double', 'path': './ConvexHullTest-PointsOnCricle1000-double.bin'} {'name': 'PointsOnCricle1000', 'prec': 'double', 'path': './ConvexHullTest-PointsOnCricle1000-double-Out.bin'}
Matrix Binary:  2 1000 8 big Endian: False
Matrix Binary:  2 1000 8 big Endian: False
PointsBadProjection {'name': 'PointsBadProjection', 'prec': 'double', 'path': './ConvexHullTest-PointsBadProjection-double.bin'} {'name': 'PointsBadProjection', 'prec': 'double', 'path': './ConvexHullTest-PointsBadProjection-double-Out.bin'}
Matrix Binary:  2 400 8 big Endian: False
Matrix Binary:  2 14 8 big Endian: False
PointsBadProjectionFilter {'name': 'PointsBadProjectionFilter', 'prec': 'double', 'path': './ConvexHullTest-PointsBadProjectionFilter-double.bin'} {'name': 'PointsBadProjectionFilter', 'prec': 'double', 'path': './ConvexHullTest-PointsBadProjectionFilter-double-Out.bin'}
Matrix Binary:  2 34 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
Points2DRectFail {'name': 'Points2DRectFail', 'prec': 'double', 'path': './ConvexHullTest-Points2DRectFail-double.bin'} {'name': 'Points2DRectFail', 'prec': 'double', 'path': './ConvexHullTest-Points2DRectFail-double-Out.bin'}
/opt/python3.4Env/lib/python3.4/site-packages/matplotlib/text.py:2130: UserWarning: You have used the `textcoords` kwarg, but not the `xytext` kwarg.  This can lead to surprising results.
  warnings.warn("You have used the `textcoords` kwarg, but not "
Matrix Binary:  2 18 8 big Endian: False
Matrix Binary:  2 8 8 big Endian: False
Point {'name': 'Point', 'prec': 'double', 'path': './ConvexHullTest-Point-double.bin'} {'name': 'Point', 'prec': 'double', 'path': './ConvexHullTest-Point-double-Out.bin'}
Matrix Binary:  2 1 8 big Endian: False
Matrix Binary:  2 1 8 big Endian: False
PointsBadProjection3 {'name': 'PointsBadProjection3', 'prec': 'double', 'path': './ConvexHullTest-PointsBadProjection3-double.bin'} {'name': 'PointsBadProjection3', 'prec': 'double', 'path': './ConvexHullTest-PointsBadProjection3-double-Out.bin'}
Matrix Binary:  2 400 8 big Endian: False
Matrix Binary:  2 8 8 big Endian: False
PointsBadProjection2 {'name': 'PointsBadProjection2', 'prec': 'double', 'path': './ConvexHullTest-PointsBadProjection2-double.bin'} {'name': 'PointsBadProjection2', 'prec': 'double', 'path': './ConvexHullTest-PointsBadProjection2-double-Out.bin'}
Matrix Binary:  2 400 8 big Endian: False
Matrix Binary:  2 10 8 big Endian: False
Line_2 {'name': 'Line_2', 'prec': 'double', 'path': './ConvexHullTest-Line_2-double.bin'} {'name': 'Line_2', 'prec': 'double', 'path': './ConvexHullTest-Line_2-double-Out.bin'}
Matrix Binary:  2 2 8 big Endian: False
Matrix Binary:  2 2 8 big Endian: False
PointsBadProjection5 {'name': 'PointsBadProjection5', 'prec': 'double', 'path': './ConvexHullTest-PointsBadProjection5-double.bin'} {'name': 'PointsBadProjection5', 'prec': 'double', 'path': './ConvexHullTest-PointsBadProjection5-double-Out.bin'}
Matrix Binary:  2 5 8 big Endian: False
Matrix Binary:  2 4 8 big Endian: False
Line4 {'name': 'Line4', 'prec': 'double', 'path': './ConvexHullTest-Line4-double.bin'} {'name': 'Line4', 'prec': 'double', 'path': './ConvexHullTest-Line4-double-Out.bin'}
Matrix Binary:  2 5 8 big Endian: False
Matrix Binary:  2 3 8 big Endian: False
Line3 {'name': 'Line3', 'prec': 'double', 'path': './ConvexHullTest-Line3-double.bin'} {'name': 'Line3', 'prec': 'double', 'path': './ConvexHullTest-Line3-double-Out.bin'}
Matrix Binary:  2 3 8 big Endian: False
Matrix Binary:  2 2 8 big Endian: False
PointsBadProjection6 {'name': 'PointsBadProjection6', 'prec': 'double', 'path': './ConvexHullTest-PointsBadProjection6-double.bin'} {'name': 'PointsBadProjection6', 'prec': 'double', 'path': './ConvexHullTest-PointsBadProjection6-double-Out.bin'}
Matrix Binary:  2 100 8 big Endian: False
Matrix Binary:  2 8 8 big Endian: False
PointsRandom10 {'name': 'PointsRandom10', 'prec': 'double', 'path': './ConvexHullTest-PointsRandom10-double.bin'} {'name': 'PointsRandom10', 'prec': 'double', 'path': './ConvexHullTest-PointsRandom10-double-Out.bin'}
Matrix Binary:  2 10 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
PointsRandom14M {'name': 'PointsRandom14M', 'prec': 'double', 'path': './ConvexHullTest-PointsRandom14M-double.bin'} {'name': 'PointsRandom14M', 'prec': 'double', 'path': './ConvexHullTest-PointsRandom14M-double-Out.bin'}
Matrix Binary:  2 42 8 big Endian: False

Min Area Rectangle Tests


In [8]:
plt.close("all")

files = loadFiles("./" , ".*MinAreaRectangleTest-(.*?)-(\w+).bin", ("name","prec") );
filesOut = loadFiles("./" , ".*MinAreaRectangleTest-(.*?)-(\w+)-Out\.bin", ("name","prec"));


for i,f in files.items():
    if(i in ["NoPoint"]): continue 
        
    fOut = filesOut[i]; print(i,f,fOut)
    fig = plt.figure("MinAreaRectangleTest"+str(i),(10,10))
    ax = fig.gca();
    
    if(i!="PointsRandom10M"):
        points = readPointsMatrixBinary(f["path"]); points=np.reshape(points,(-1,2)) 
    
    rectData =  readPointsMatrixBinary(fOut["path"]); rectData=np.reshape(rectData,(-1,2))
    
    rect = rectData[0:4,]
    rect = np.vstack([rect,rect[0]])
    axis = rectData[4:,]
    print(axis)
    plt.plot(rect.T[0],rect.T[1],'r-', ms=20, markerfacecolor='None')
    
    plotAxis2d(ax,rect[0],axis[0],axis[1]);
    
    if(i!="PointsRandom10M"):
        plt.scatter(points.T[0],points.T[1])
    else:
        plt.scatter(points.T[0][0:400],points.T[1][0:400])
    plt.axis('equal')


Points2DRectFail {'prec': 'double', 'name': 'Points2DRectFail', 'path': './MinAreaRectangleTest-Points2DRectFail-double.bin'} {'prec': 'double', 'name': 'Points2DRectFail', 'path': './MinAreaRectangleTest-Points2DRectFail-double-Out.bin'}
Matrix Binary:  2 18 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
[[ 3.38826761 -2.60794988]
 [-0.39487855  0.91873333]
 [-0.91873333 -0.39487855]]
AlmostLine {'prec': 'double', 'name': 'AlmostLine', 'path': './MinAreaRectangleTest-AlmostLine-double.bin'} {'prec': 'double', 'name': 'AlmostLine', 'path': './MinAreaRectangleTest-AlmostLine-double-Out.bin'}
Matrix Binary: 
/opt/python3.4Env/lib/python3.4/site-packages/matplotlib/collections.py:590: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._edgecolors == str('face'):
/opt/python3.4Env/lib/python3.4/site-packages/matplotlib/collections.py:590: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._edgecolors == str('face'):
 2 4 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
[[ 0.          0.        ]
 [ 0.70710678  0.70710678]
 [-0.70710678  0.70710678]]
Point {'prec': 'double', 'name': 'Point', 'path': './MinAreaRectangleTest-Point-double.bin'} {'prec': 'double', 'name': 'Point', 'path': './MinAreaRectangleTest-Point-double-Out.bin'}
Matrix Binary:  2 1 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
[[ 1.  0.]
 [ 1.  0.]
 [ 0.  1.]]
TwoPoints {'prec': 'double', 'name': 'TwoPoints', 'path': './MinAreaRectangleTest-TwoPoints-double.bin'} {'prec': 'double', 'name': 'TwoPoints', 'path': './MinAreaRectangleTest-TwoPoints-double-Out.bin'}
Matrix Binary:  2 2 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
[[ 1.          0.        ]
 [ 0.5547002   0.83205029]
 [-0.83205029  0.5547002 ]]
PointsRandom10 {'prec': 'double', 'name': 'PointsRandom10', 'path': './MinAreaRectangleTest-PointsRandom10-double.bin'} {'prec': 'double', 'name': 'PointsRandom10', 'path': './MinAreaRectangleTest-PointsRandom10-double-Out.bin'}
Matrix Binary:  2 10 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
[[ 0.95782081  0.95453227]
 [-0.91190368 -0.41040429]
 [ 0.41040429 -0.91190368]]
PointsRandom10M {'prec': 'double', 'name': 'PointsRandom10M', 'path': './MinAreaRectangleTest-PointsRandom10M-double.bin'} {'prec': 'double', 'name': 'PointsRandom10M', 'path': './MinAreaRectangleTest-PointsRandom10M-double-Out.bin'}
Matrix Binary:  2 7 8 big Endian: False
[[  9.99999818e-01   1.82427005e-07]
 [ -8.15560543e-08   1.00000000e+00]
 [ -1.00000000e+00  -8.15560543e-08]]
PointsBadProjection2 {'prec': 'double', 'name': 'PointsBadProjection2', 'path': './MinAreaRectangleTest-PointsBadProjection2-double.bin'} {'prec': 'double', 'name': 'PointsBadProjection2', 'path': './MinAreaRectangleTest-PointsBadProjection2-double-Out.bin'}
Matrix Binary:  2 400 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
[[ 3.16181212  5.70506863]
 [-0.99843392  0.05594372]
 [-0.05594372 -0.99843392]]
RandomTriangle {'prec': 'double', 'name': 'RandomTriangle', 'path': './MinAreaRectangleTest-RandomTriangle-double.bin'} {'prec': 'double', 'name': 'RandomTriangle', 'path': './MinAreaRectangleTest-RandomTriangle-double-Out.bin'}
Matrix Binary:  2 3 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
[[ 0.22053406  0.68698046]
 [ 0.99700658  0.07731678]
 [-0.07731678  0.99700658]]
PointsBadProjection3 {'prec': 'double', 'name': 'PointsBadProjection3', 'path': './MinAreaRectangleTest-PointsBadProjection3-double.bin'} {'prec': 'double', 'name': 'PointsBadProjection3', 'path': './MinAreaRectangleTest-PointsBadProjection3-double-Out.bin'}
Matrix Binary:  2 400 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
[[ 1.43898234 -5.6280445 ]
 [ 0.57332627  0.81932715]
 [-0.81932715  0.57332627]]
UnitRectangle {'prec': 'double', 'name': 'UnitRectangle', 'path': './MinAreaRectangleTest-UnitRectangle-double.bin'} {'prec': 'double', 'name': 'UnitRectangle', 'path': './MinAreaRectangleTest-UnitRectangle-double-Out.bin'}
Matrix Binary:  2 4 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
[[  1.00000000e+00   1.00000000e+00]
 [ -1.00000000e+00   2.22044605e-16]
 [ -2.22044605e-16  -1.00000000e+00]]
PointsOnCricle1000 {'prec': 'double', 'name': 'PointsOnCricle1000', 'path': './MinAreaRectangleTest-PointsOnCricle1000-double.bin'} {'prec': 'double', 'name': 'PointsOnCricle1000', 'path': './MinAreaRectangleTest-PointsOnCricle1000-double-Out.bin'}
Matrix Binary:  2 1000 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
[[  9.99999995e-01   9.98999998e-05]
 [  4.99499997e-05  -9.99999999e-01]
 [  9.99999999e-01   4.99499997e-05]]
Triangle {'prec': 'double', 'name': 'Triangle', 'path': './MinAreaRectangleTest-Triangle-double.bin'} {'prec': 'double', 'name': 'Triangle', 'path': './MinAreaRectangleTest-Triangle-double-Out.bin'}
Matrix Binary:  2 3 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
[[  1.00000000e+00  -1.00000000e+00]
 [  1.11022302e-16   1.00000000e+00]
 [ -1.00000000e+00   1.11022302e-16]]
Line2 {'prec': 'double', 'name': 'Line2', 'path': './MinAreaRectangleTest-Line2-double.bin'} {'prec': 'double', 'name': 'Line2', 'path': './MinAreaRectangleTest-Line2-double-Out.bin'}
Matrix Binary:  2 2 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
[[ 0.          0.        ]
 [ 0.70710678  0.70710678]
 [-0.70710678  0.70710678]]
Line3 {'prec': 'double', 'name': 'Line3', 'path': './MinAreaRectangleTest-Line3-double.bin'} {'prec': 'double', 'name': 'Line3', 'path': './MinAreaRectangleTest-Line3-double-Out.bin'}
Matrix Binary:  2 3 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
[[ 0.          0.        ]
 [ 0.70710678  0.70710678]
 [-0.70710678  0.70710678]]
PointsBadProjection {'prec': 'double', 'name': 'PointsBadProjection', 'path': './MinAreaRectangleTest-PointsBadProjection-double.bin'} {'prec': 'double', 'name': 'PointsBadProjection', 'path': './MinAreaRectangleTest-PointsBadProjection-double-Out.bin'}
Matrix Binary:  2 400 8 big Endian: False
Matrix Binary:  2 7 8 big Endian: False
[[ 1.1210723  -3.36871442]
 [-0.05435405  0.99852173]
 [-0.99852173 -0.05435405]]

Diameter MVBB Tests


In [107]:
plt.close("all")

files = loadFiles("./" , ".*DiameterOOBBTest-(.*?)-(\w+)\.bin", ("name","prec") );
filesOut = loadFiles("./" , ".*DiameterOOBBTest-(.*?)-(\w+)-Out\.txt", ("name","prec") );
filesOut2 = loadFiles("./" , ".*DiameterOOBBTest-(.*?)-(\w+)-Out2\.bin", ("name","prec") );

for i,f in files.items():
        
    fOut = filesOut[i]; fOut2 = filesOut2[i]; print(i,f,fOut,fOut2)
    fig = plt.figure("DiameterTest"+str(i),(10,10))
    
    points = readPointsMatrixBinary(f["path"]); points=np.reshape(points,(-1,3)) 
    OOBB = np.atleast_2d(np.loadtxt(fOut["path"]));
    sampled = readPointsMatrixBinary(fOut2["path"]); sampled=np.reshape(sampled,(-1,3)) 

    K_min = OOBB[0,0:3]
    K_max = OOBB[1,0:3]
    A_IK = OOBB[2:,0:3]
    center = np.zeros((3,));
    #print(A_IK,K_min,K_max,center)

    ax = Axes3D(fig)
    if(i not in ["PointsRandom14M", "Lucy"] ):
        ax.scatter(points.T[0],points.T[1],points.T[2],c='b')
    else:
        plt.scatter(points.T[0][0:2000],points.T[1][0:2000])
    
    ax.scatter(sampled.T[0],sampled.T[1],sampled.T[2],c='r', marker='o', s=200)
    plotCube(ax,K_min,K_max,center,A_IK) # A_IK = R_KI (rotation from I to K)
    plotAxis(ax,center,A_IK,1)
    plotAxis(ax,center,np.identity(3),0.5)
    axisEqual3D(ax)


Plane {'path': './DiameterOOBBTest-Plane-double.bin', 'name': 'Plane', 'prec': 'double'} {'path': './DiameterOOBBTest-Plane-double-Out.txt', 'name': 'Plane', 'prec': 'double'} {'path': './DiameterOOBBTest-Plane-double-Out2.bin', 'name': 'Plane', 'prec': 'double'}
Matrix Binary:  3 3 8 big Endian: False
Matrix Binary:  3 2 8 big Endian: False
UnitCube {'path': './DiameterOOBBTest-UnitCube-double.bin', 'name': 'UnitCube', 'prec': 'double'} {'path': './DiameterOOBBTest-UnitCube-double-Out.txt', 'name': 'UnitCube', 'prec': 'double'} {'path': './DiameterOOBBTest-UnitCube-double-Out2.bin', 'name': 'UnitCube', 'prec': 'double'}
Matrix Binary:  3 8 8 big Endian: False
Matrix Binary:  3 4 8 big Endian: False
PointsSimulationFailMVBB {'path': './DiameterOOBBTest-PointsSimulationFailMVBB-double.bin', 'name': 'PointsSimulationFailMVBB', 'prec': 'double'} {'path': './DiameterOOBBTest-PointsSimulationFailMVBB-double-Out.txt', 'name': 'PointsSimulationFailMVBB', 'prec': 'double'} {'path': './DiameterOOBBTest-PointsSimulationFailMVBB-double-Out2.bin', 'name': 'PointsSimulationFailMVBB', 'prec': 'double'}
Matrix Binary:  3 2501 8 big Endian: False
Matrix Binary:  3 400 8 big Endian: False
PointsRandom10000 {'path': './DiameterOOBBTest-PointsRandom10000-double.bin', 'name': 'PointsRandom10000', 'prec': 'double'} {'path': './DiameterOOBBTest-PointsRandom10000-double-Out.txt', 'name': 'PointsRandom10000', 'prec': 'double'} {'path': './DiameterOOBBTest-PointsRandom10000-double-Out2.bin', 'name': 'PointsRandom10000', 'prec': 'double'}
Matrix Binary:  3 10000 8 big Endian: False
Matrix Binary:  3 400 8 big Endian: False
PointsSimulation {'path': './DiameterOOBBTest-PointsSimulation-double.bin', 'name': 'PointsSimulation', 'prec': 'double'} {'path': './DiameterOOBBTest-PointsSimulation-double-Out.txt', 'name': 'PointsSimulation', 'prec': 'double'} {'path': './DiameterOOBBTest-PointsSimulation-double-Out2.bin', 'name': 'PointsSimulation', 'prec': 'double'}
Matrix Binary:  3 2501 8 big Endian: False
Matrix Binary:  3 400 8 big Endian: False
PointsRandom500 {'path': './DiameterOOBBTest-PointsRandom500-double.bin', 'name': 'PointsRandom500', 'prec': 'double'} {'path': './DiameterOOBBTest-PointsRandom500-double-Out.txt', 'name': 'PointsRandom500', 'prec': 'double'} {'path': './DiameterOOBBTest-PointsRandom500-double-Out2.bin', 'name': 'PointsRandom500', 'prec': 'double'}
Matrix Binary:  3 500 8 big Endian: False
Matrix Binary:  3 400 8 big Endian: False
/opt/python3.4Env/lib/python3.4/site-packages/matplotlib/collections.py:590: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._edgecolors == str('face'):

MVBB Tests


In [7]:
plt.close("all")

files = loadFiles("./" , ".*MVBBTest-(.*?)-(\w+).bin", ("name","prec") );
filesOut = loadFiles("./" , ".*MVBBTest-(.*?)-(\w+)-Out\.txt", ("name","prec"));


for i,f in files.items():

    fOut = filesOut[i]; 
    print(i,f,fOut);
    fig = plt.figure("MVBBTest" + str(i),(10,10))
    
    
    points = readPointsMatrixBinary(f["path"]); points=np.reshape(points,(-1,3)) 
    OOBB = np.atleast_2d(np.loadtxt(fOut["path"]));

    K_min = OOBB[0,0:3]
    K_max = OOBB[1,0:3]
    A_IK = OOBB[2:5,0:3]
    center = np.zeros((3,));
    print(A_IK,K_min,K_max,center)
    
    ax = Axes3D(fig)
    if(len(points) < 10000):
        ax.scatter(points.T[0],points.T[1],points.T[2],c='b')
    else:
        ax.scatter(points.T[0][0:10000],points.T[1][0:10000],points.T[2][0:10000],c='b')
        
    plotCube(ax,K_min,K_max,center,A_IK) # A_IK = R_KI (rotation from I to K)
    plotAxis(ax,center,A_IK,1)
    plotAxis(ax,center,np.identity(3),0.5)
    axisEqual3D(ax)


PointClouds-Nr-3 {'name': 'PointClouds-Nr-3', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-3-double.bin'} {'name': 'PointClouds-Nr-3', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-3-double-Out.txt'}
Matrix Binary:  3 2501 8 big Endian: False
[[ 0.70869138 -0.49319411  0.50449588]
 [ 0.63834646  0.14372591 -0.75621205]
 [ 0.3004502   0.85796412  0.41668603]] [-1.42661565 -3.86197932 -1.84620041] [ 5.34794633  0.33660258  5.23716277] [ 0.  0.  0.]
PointClouds-Nr-2 {'name': 'PointClouds-Nr-2', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-2-double.bin'} {'name': 'PointClouds-Nr-2', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-2-double-Out.txt'}
Matrix Binary:  3 2501 8 big Endian: False
[[ 0.10556901  0.99296013 -0.05371568]
 [ 0.31158544 -0.08432764 -0.94646889]
 [-0.94433559  0.08318076 -0.3182943 ]] [-2.75246443  0.47313016 -5.80166171] [ 4.34356251  3.28634465  1.24852591] [ 0.  0.  0.]
PointClouds-Nr-0 {'name': 'PointClouds-Nr-0', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-0-double.bin'} {'name': 'PointClouds-Nr-0', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-0-double-Out.txt'}
Matrix Binary:  3 2501 8 big Endian: False
[[-0.67326785  0.72861482 -0.1258207 ]
 [-0.12721436 -0.28177578 -0.95100942]
 [-0.72837278 -0.62427787  0.28240084]] [-3.07889923  0.06567176 -2.56760063] [ 1.46037201  2.70302304  1.97016091] [ 0.  0.  0.]
PointClouds-Nr-1 {'name': 'PointClouds-Nr-1', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-1-double.bin'} {'name': 'PointClouds-Nr-1', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-1-double-Out.txt'}
Matrix Binary:  3 2501 8 big Endian: False
[[ 0.71790551  0.3225827  -0.61688903]
 [-0.49581552 -0.38509148 -0.7783775 ]
 [-0.48864982  0.86466465 -0.11651779]] [-3.7118524  -1.98637348 -3.588783  ] [ 1.95426225  3.62481662 -0.85203934] [ 0.  0.  0.]
PointClouds-Nr-5 {'name': 'PointClouds-Nr-5', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-5-double.bin'} {'name': 'PointClouds-Nr-5', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-5-double-Out.txt'}
Matrix Binary:  3 2501 8 big Endian: False
[[-0.42217616 -0.81731231 -0.39213248]
 [-0.69052784  0.00968801  0.72324093]
 [-0.58731473  0.57611347 -0.56846695]] [-5.20026337 -3.69057488 -3.25279152] [ 0.02893903  1.76741518  2.60115356] [ 0.  0.  0.]
PointClouds-Nr-4 {'name': 'PointClouds-Nr-4', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-4-double.bin'} {'name': 'PointClouds-Nr-4', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-4-double-Out.txt'}
Matrix Binary:  3 2501 8 big Endian: False
[[-0.5726534  -0.60236496  0.55607962]
 [-0.59910837  0.77050971  0.21767855]
 [-0.55958668 -0.2084976  -0.80211689]] [-4.80008815 -3.87343944 -3.96441211] [ 0.69617304  2.06699221  2.01829794] [ 0.  0.  0.]
PointClouds-Nr-9 {'name': 'PointClouds-Nr-9', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-9-double.bin'} {'name': 'PointClouds-Nr-9', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-9-double-Out.txt'}
Matrix Binary:  3 2501 8 big Endian: False
[[ 0.79753714 -0.33199973 -0.50369702]
 [ 0.51391843  0.811184    0.27904905]
 [ 0.31594675 -0.48141116  0.81757015]] [-1.50647084 -3.63294126 -1.71404585] [ 5.51640073  4.3488506   2.03292811] [ 0.  0.  0.]
PointClouds-Nr-6 {'name': 'PointClouds-Nr-6', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-6-double.bin'} {'name': 'PointClouds-Nr-6', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-6-double-Out.txt'}
Matrix Binary:  3 2501 8 big Endian: False
[[ 0.40071774  0.84480005  0.35459579]
 [-0.86700551  0.47476635 -0.15132202]
 [-0.296187   -0.24679909  0.9226936 ]] [-4.10844183 -0.31695178 -0.30692678] [ 2.17617083  4.12642096  4.31170007] [ 0.  0.  0.]
PointClouds-Nr-7 {'name': 'PointClouds-Nr-7', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-7-double.bin'} {'name': 'PointClouds-Nr-7', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-7-double-Out.txt'}
Matrix Binary:  3 2501 8 big Endian: False
[[ 0.84772018  0.20510971 -0.48918351]
 [ 0.06008722  0.87914833  0.4727449 ]
 [ 0.52702943 -0.43014907  0.73294731]] [-0.39393158 -2.65702974  0.50217223] [ 3.90889747  3.6933134   5.19834765] [ 0.  0.  0.]
PointClouds-Nr-8 {'name': 'PointClouds-Nr-8', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-8-double.bin'} {'name': 'PointClouds-Nr-8', 'prec': 'double', 'path': './MVBBTest-PointClouds-Nr-8-double-Out.txt'}
Matrix Binary:  3 2501 8 big Endian: False
[[-0.34365444 -0.0969246   0.93408097]
 [-0.3375783   0.94092259 -0.02656272]
 [-0.8763233  -0.32445386 -0.35607186]] [-5.02406698 -2.44769914 -2.22532513] [-0.01006527  3.0529593   2.29540345] [ 0.  0.  0.]

In [ ]: