示例#1
0
    def transform(self, trans):
        trans = svg.cannonical_transformation(trans)

        oldx, oldy = self.x, self.y
        self.x, self.y = trans(self.x, self.y)

        if self.rotate:
            shiftx, shifty = trans(oldx + epsilon, oldy)
            angle = math.atan2(shifty, shiftx)
            trans = eval(
                "lambda x, y: (%(newx)s + cos(%(angle)s)*(x - %(oldx)s) - sin(%(angle)s)*(y - %(oldy)s), %(newy)s + sin(%(angle)s)*(x - %(oldx)s) + cos(%(angle)s)*(y - %(oldy)s))"
                % {
                    "newx": repr(self.x),
                    "newy": repr(self.y),
                    "oldx": repr(oldx),
                    "oldy": repr(oldy),
                    "angle": repr(angle)
                }, math.__dict__)

        else:
            trans = eval(
                "lambda x, y: (x + %(newx)s - %(oldx)s, y + %(newy)s - %(oldy)s)"
                % {
                    "newx": repr(self.x),
                    "newy": repr(self.y),
                    "oldx": repr(oldx),
                    "oldy": repr(oldy)
                })

        for child in self.children:
            if isinstance(child, svg.SVG): child.transform(trans)
示例#2
0
def transformation_jacobian(expr, x, y, scale=1.):
  func = svg.cannonical_transformation(expr)
  eps = epsilon
  if scale != 0.: eps *= scale

  X0, Y0 = func(x, y)
  xhatx, xhaty = func(x + eps, y)
  yhatx, yhaty = func(x, y + eps)

  return (1.*(xhatx - X0)/eps, 1.*(xhaty - Y0)/eps), (1.*(yhatx - X0)/eps, 1.*(yhaty - Y0)/eps)
示例#3
0
def transformation_angle(expr, x, y, scale=1.):
  func = svg.cannonical_transformation(expr)
  eps = epsilon
  if scale != 0.: eps *= scale

  xprime, yprime = func(x + eps, y)
  x, y = func(x, y)

  delx, dely = xprime - x, yprime - y
  return math.atan2(dely, delx)
示例#4
0
def transform(trans, obj):
  if isinstance(trans, basestring):
    trans = svg.cannonical_transformation(trans)

  obj = copy.deepcopy(obj)
  if callable(trans):
    obj.transform(trans)
  else:
    for t in trans: obj.transform(t)
  return obj
示例#5
0
def transformation_angle(expr, x, y, scale=1.):
    func = svg.cannonical_transformation(expr)
    eps = epsilon
    if scale != 0.: eps *= scale

    xprime, yprime = func(x + eps, y)
    x, y = func(x, y)

    delx, dely = xprime - x, yprime - y
    return math.atan2(dely, delx)
示例#6
0
def transform(trans, obj):
    if isinstance(trans, basestring):
        trans = svg.cannonical_transformation(trans)

    obj = copy.deepcopy(obj)
    if callable(trans):
        obj.transform(trans)
    else:
        for t in trans:
            obj.transform(t)
    return obj
示例#7
0
def transformation_jacobian(expr, x, y, scale=1.):
    func = svg.cannonical_transformation(expr)
    eps = epsilon
    if scale != 0.: eps *= scale

    X0, Y0 = func(x, y)
    xhatx, xhaty = func(x + eps, y)
    yhatx, yhaty = func(x, y + eps)

    return (1. * (xhatx - X0) / eps,
            1. * (xhaty - Y0) / eps), (1. * (yhatx - X0) / eps,
                                       1. * (yhaty - Y0) / eps)
示例#8
0
  def transform(self, trans):
    trans = svg.cannonical_transformation(trans)

    oldx, oldy = self.x, self.y
    self.x, self.y = trans(self.x, self.y)

    if self.rotate:
      shiftx, shifty = trans(oldx + epsilon, oldy)
      angle = math.atan2(shifty, shiftx)
      trans = eval("lambda x, y: (%(newx)s + cos(%(angle)s)*(x - %(oldx)s) - sin(%(angle)s)*(y - %(oldy)s), %(newy)s + sin(%(angle)s)*(x - %(oldx)s) + cos(%(angle)s)*(y - %(oldy)s))" % {"newx": repr(self.x), "newy": repr(self.y), "oldx": repr(oldx), "oldy": repr(oldy), "angle": repr(angle)}, math.__dict__)

    else:
      trans = eval("lambda x, y: (x + %(newx)s - %(oldx)s, y + %(newy)s - %(oldy)s)" %
                   {"newx": repr(self.x), "newy": repr(self.y), "oldx": repr(oldx), "oldy": repr(oldy)})

    for child in self.children:
      if isinstance(child, svg.SVG): child.transform(trans)
示例#9
0
 def transform(self, trans):
   self.trans.append(svg.cannonical_transformation(trans))
示例#10
0
文件: curve.py 项目: slowriot/voro--
  def transform(self, t): self.trans.append(svg.cannonical_transformation(t))

  def bbox(self): return pathdata.bbox(self.d())
示例#11
0
 def transform(self, trans):
     self.trans.append(svg.cannonical_transformation(trans))
示例#12
0
文件: plot.py 项目: slowriot/voro--
 def transform(self, t):
   t = svg.cannonical_transformation(t)
   x1, y1 = t(self.x, self.y)
   x2, y2 = t(self.x + self.width, self.y + self.height)
   self.x, self.y = x1, y1
   self.width, self.height = x2 - x1, y2 - y1