コード例 #1
0
ファイル: test_bump.py プロジェクト: rbianchi66/pyqt_md
def shape(r1, r2, nvertices, xl = P(0, 0)):
    res = Path()
    for i in range(nvertices):
        a = i * 2 * PI / nvertices;
        p1 = r1 * P(sin(a), cos(a)) + xl
        a += PI / nvertices
        p2 = r2 * P(sin(a), cos(a)) + xl
        res.append(p1)
        res.append(p2)
    res.append(res[0])
    return res
コード例 #2
0
ファイル: test_matching.py プロジェクト: rbianchi66/pyqt_md
    def testHalfSquareOverSquare(self):
        """
        Sovrapposizione di un mezzo quadrato su un quadrato
        """
        sq = Path([P(0,0), P(10,0), P(17,0), P(80,0), P(100,0), P(100,100), P(0,100), P(0,0)])
        hsq = Path([P(100,100), P(0,100), P(0,0)]) * rot(random.random()*2*math.pi) * xlate(P(random.random()*self.sf, random.random()*self.sf))
        mr = pathOverPath(hsq, sq, 10)

        self.assertAlmostEquals(mr.sse/mr.n, 0.0)
        A = X(mr.A)
        for p1 in hsq: # controllo della distanza punto-path
            self.assertAlmostEquals(sq.project(p1*A).dist, 0, tollerance)
コード例 #3
0
ファイル: test_matching.py プロジェクト: rbianchi66/pyqt_md
 def testTwoLinesOverSquare(self):
     """
     Ripetizione del test del caso vecpathOverPath
     """
     square = Path([P(0,0), P(0, 100), P(100,100), P(100,0), P(0,0)])
     T = rot(random.random()*2*math.pi) * xlate(P(random.random()*self.sf, random.random()*self.sf))
     seg1 = Path([P(1,1), P(1,61)]) * T
     seg2 = Path([P(101,101), P(101,61)]) * T
     mr = vecpathOverVecpath([seg1, seg2], [square], 1, 10, 1)[0]
     A = X(mr.A)
     self.assertAlmostEquals(mr.sse/mr.n, 0.0)
     for p1 in list(seg1)+list(seg2): # controllo della distanza punto-path
         self.assertAlmostEquals(square.project(p1*A).dist, 0, tollerance)
コード例 #4
0
ファイル: test_matching.py プロジェクト: rbianchi66/pyqt_md
    def testGetWeights(self):
        """
        Controlla la correttezza della funzione get_weights.
        Esegue un'interpolazione lineare dei pesi
        """
        path = Path([P(x,0) for x in xrange(101)])
        weight = [ x for x in xrange(101) ]
        dts = get_weights(path, weight, list(path))
        for d, w in zip(dts, weight):
            self.assertAlmostEqual(d, w)

        rx = random.random()*path.len()
        dts = get_weights(path, weight, [P(rx, 0)] )
        self.assertAlmostEqual(dts[0], rx)
コード例 #5
0
ファイル: test_matching.py プロジェクト: rbianchi66/pyqt_md
 def testTwoLinesOverSquare(self):
     """
     Dato un quadrato e 2 suoi lati, la funzione deve restituire la matrice di rototraslazione per
     sovrapporre i 2 lati al quadrato originale
     """
     square = Path([P(0,0), P(0, 100), P(100,100), P(100,0), P(0,0)])
     T = rot(random.random()*2*math.pi) * xlate(P(random.random()*self.sf, random.random()*self.sf))
     seg1 = Path([P(1,1), P(1,61)]) * T
     seg2 = Path([P(101,101), P(101,61)]) * T
     mr = vecpathOverPath([seg1, seg2], square, 10)
     A = X(mr.A)
     self.assertAlmostEquals(mr.sse/mr.n, 0.0)
     for p1 in list(seg1)+list(seg2): # controllo della distanza punto-path
         self.assertAlmostEquals(square.project(p1*A).dist, 0, tollerance)
コード例 #6
0
ファイル: test_matching.py プロジェクト: rbianchi66/pyqt_md
 def testHalfCircleOverHalfCircle(self):
     """
     La funzione deve sovrapporre due semicerchi identici, dopo che uno di questi e'
     stato traslato e ruotato
     """
     O1 = P(0,0)
     O2 = P(100,100)
     c1 = Path( circle(O1, 100, minpts= 100, maxerr=100)[0:50] )
     c2 = Path( c1 ) * rot(random.random()*2*math.pi) * xlate(O2)
     mr = pathOverPath(c2, c1, 10)
     self.assertAlmostEquals(mr.sse/mr.n, 0.0)
     A = X(mr.A)
     for p1, p2 in zip(c1, c2): # controllo della distanza punto-path
         self.assertAlmostEquals(c1.project(p2*A).dist, 0, tollerance)
コード例 #7
0
ファイル: test_matching.py プロジェクト: rbianchi66/pyqt_md
    def testQuarterCircleOverHalfCircle(self):
        """
        La funzione deve sovrapporre un quarto-di-cerchio a un semicerchio, dopo che
        il quarto-di-cerchio e' stato traslato e ruotato
        """
        O1 = P(0,0)
        O2 = P(100,100)
        c1 = Path( circle(O1, 100, minpts= 100, maxerr=100)[0:50] )
        c2 = Path( c1[0:25] ) * rot(random.random()*2*math.pi) * xlate(O2)
        mr = pathOverPath(c2, c1, 10)

        self.assertAlmostEquals(mr.sse/mr.n, 0.0)
        A = X(mr.A)
        for p2 in c2: # controllo della distanza punto-path
            self.assertAlmostEquals(c1.project(p2*A).dist, 0, tollerance)
コード例 #8
0
ファイル: test_matching.py プロジェクト: rbianchi66/pyqt_md
    def testTwoLinesOverTwoLines(self):
        """
        La funzione deve tornare la matrice di rototraslazione per queste quatro linee sovrapponibili
        due a due
        """
        T = rot(random.random()*2*math.pi) * xlate(P(random.random()*self.sf, random.random()*self.sf))
        W = rot(random.random()*2*math.pi) * xlate(P(random.random()*self.sf, random.random()*self.sf))

        s1T = Path([P(1,1), P(1,61)]) * T
        s2T = Path([P(101,101), P(101,61)]) * T

        s1W = Path([P(1,1), P(1,61)]) * W
        s2W = Path([P(101,101), P(101,61)]) * W

        #Per avere una sovrapposizione piu' esatta possibile, diminuisco il passo a 1mm
        mr = vecpathOverVecpath([s1T, s2T], [s1W, s2W], 1, 10, 1)[0]
        self.assertNotEqual(mr.n, -1) # Risultato invalido
        A = X(mr.A)
        self.assertAlmostEquals(mr.sse/mr.n, 0.0)
        for p1 in s1T:
            self.assertAlmostEquals(s1W.project(p1*A).dist, 0, tollerance)
        for p2 in s2T:
            self.assertAlmostEquals(s2W.project(p2*A).dist, 0, tollerance)
コード例 #9
0
ファイル: test_matching.py プロジェクト: rbianchi66/pyqt_md
    def testReverseQuarterCircleOverHalfCircle(self):
        """
        La funzione deve sovrapporre un quarto-di-cerchio a un semicerchio, dopo che
        il quarto-di-cerchio e' stato traslato e ruotato.
        L'ordine dei punti del quarto di cerchio viene invertito (senso antiorario).

        Si nota che l'errore di accostamento dei due path sale a causa di una non piu' perfetta
        corrispondenza nella scelta dei punti (dato che i path "cominciano" da due punti differenti)
        """
        O1 = P(0,0)
        O2 = P(100,100)
        c1 = Path( circle(O1, 100, minpts= 100, maxerr=100)[0:50] )
        tmp = c1[25:50]
        tmp.reverse()
        c2 = Path( tmp ) * rot(random.random()*2*math.pi) * xlate(O2)
        # Per passare questo test e' necessario alzare la risoluzione a 1mm
        mr = pathOverPath(c2, c1, 1)

        self.assertAlmostEquals(mr.sse/mr.n, 0.0)
        A = X(mr.A)
        for p2 in c2: # controllo della distanza punto-path
            # Per passare questo test e' necessario alzare la tolleranza
            self.assertAlmostEquals(c1.project(p2*A).dist,0, tollerance)