Exemplo n.º 1
0
    def connectivity_analysis(self,other):
        
        
        COM_self = contour_utilities.get_com(self.verts_simple)
        COM_other = contour_utilities.get_com(other.verts_simple)
        delta_com_vect = COM_self - COM_other  #final - initial :: self - other
        delta_com_vect.normalize()
        

        
        ideal_to_com = 0
        for i, v in enumerate(self.verts_simple):
            connector = v - other.verts_simple[i]  #continue convention of final - initial :: self - other
            connector.normalize()
            align = connector.dot(delta_com_vect)
            #this shouldnt happen but it appears to be...shrug
            if align < 0:
                print('damn reverse!')
                print(align)
                align *= -1    
            ideal_to_com += align
        
        ideal_to_com = 1/len(self.verts_simple) * ideal_to_com
        
        return ideal_to_com
Exemplo n.º 2
0
 def analyze_relationship(self, other,debug = False):
     '''
     runs a series of quantitative assemsents of the spatial relationship
     to another cut line to assist in anticipating the the optimized
     connectivity data
     
     assume the other cutline has already been solidified and the only variation
     which can happen is on this line
     '''
     #requirements
     # both loops must have a verts simple
     
     
     #caclulate the center of mass of each loop using existing
     #verts simple since they are evenly spaced it will be a
     #good example
     COM_other = contour_utilities.get_com(other.verts_simple)
     COM_self = contour_utilities.get_com(self.verts_simple)
     
     #the vector pointing from the COM of the other cutline
     #to this cutline.  This will be our convention for
     #positive direciton
     delta_com_vect = COM_self - COM_other  
     #delta_com_vect.normalize()
     
     #the plane normals
     self_no = self.plane_no.copy()
     other_no = other.plane_no.copy()
     
     #if for some reason they aren't normalized...fix that
     self_no.normalize()
     other_no.normalize()
     
     #make sure the other normal is aligned with
     #the line from other to self for convention
     if other_no.dot(delta_com_vect) < 0:
         other_no = -1 * other_no
         
     #and now finally make the self normal is aligned too    
     if self_no.dot(other_no) < 0:
         self_no = -1 * self_no
     
     #how parallel are the loops?
     parallelism = self_no.dot(other_no)
     if debug > 1:
         print('loop paralellism = %f' % parallelism)
     
     #this may be important.
     avg_no = self_no.lerp(other_no, 0.5)
     
     #are the loops aimed at one another?
     #compare the delta COM vector to each normal
     self_aimed_other = self_no.dot(delta_com_vect.normalized())
     other_aimed_self = other_no.dot(delta_com_vect.normalized())
     
     aiming_difference = self_aimed_other - other_aimed_self
     if debug > 1:
         print('aiming difference = %f' % aiming_difference)
     #do we expect divergence or convergence?
     #remember other -> self is positive so enlarging
     #while traveling in this direction is divergence
     radi_self = contour_utilities.approx_radius(self.verts_simple, COM_self)
     radi_other = contour_utilities.approx_radius(other.verts_simple, COM_other)
     
     #if divergent or convergent....we will want to maximize
     #the opposite phenomenon with respect to the individual
     #connectors and teh delta COM line
     divergent = (radi_self - radi_other) > 0
     divergence = (radi_self - radi_other)**2 / ((radi_self - radi_other)**2 + delta_com_vect.length**2)
     divergence = math.pow(divergence, 0.5)
     if debug > 1:
         print('the loops are divergent: ' + str(divergent) + ' with a divergence of: ' + str(divergence))
     
     return [COM_self, delta_com_vect, divergent, divergence]
Exemplo n.º 3
0
 def update_com(self):
     if self.verts_simple != []:
         self.plane_com = contour_utilities.get_com(self.verts_simple)
     else:
         self.plane_com = None