# Phil 12.16.2021

`# Repulsion function.  `self' and `n2` should be nodes.  This will# adjust the dx and dy values of `self`  `n2`. If you want objects with more mass to be given# 'more room', set common_mass to zerodef linRepulsion(self, n2:'ForceNode', common_mass:float = 1.0):    xDist = self.x - n2.x    yDist = self.y - n2.y    distance2 = xDist * xDist + yDist * yDist  # Distance squared    if distance2 > 0:        if common_mass == 0:            common_mass = self.mass        factor = self.pp.repulsion_scalar * common_mass / distance2        self.dx += xDist * factor        self.dy += yDist * factor`
`def adjust_mass_size(self, mass:float = 0, size:float = 0, scalar:float=0 ):    #set up the scalar regardless    if mass == 0 and scalar == 0:        print("WARNING! CanvasFrame.adjust_node(): mass == 0 and scalar == 0")        return    if scalar == 0 and size != 0:        scalar =  size / self.size    if mass != 0:        self.mass = mass    else:        self.mass *= scalar    # now just use the scalar. The reason we do this is that the call to self.canvas.coords() returns    # a SCALED value of coordinates. If we set them directly from size, they will be too big if    # zoomed out and too small if zoomed in    self.size *= scalar    x0, y0, x1, y1 = self.cd.canvas.coords(self.id)    old_x_size = abs(x1 - x0)    old_y_size = abs(y1 - y0)    x_size = old_x_size * scalar    y_size = old_y_size * scalar    x_offset = (x_size - old_x_size)/2.0    y_offset = (y_size - old_y_size)/2.0    self.cd.canvas.coords(self.id, x0-x_offset, y0-y_offset, x1+x_offset, y1+y_offset)`