Esempio n. 1
0
 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)
Esempio n. 2
0
    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)