def add_origin(ax, geom, origin): x, y = xy = affinity.interpret_origin(geom, origin, 2) ax.plot(x, y, 'o', color=GRAY, zorder=1) ax.annotate(str(xy), xy=xy, ha='center', textcoords='offset points', xytext=(0, 8))
def add_origin(ax, geom, origin): x, y = xy = affinity.interpret_origin(geom, origin, 2) ax.plot(x, y, 'o', color=GRAY, zorder=1) ax.annotate(str(xy), xy=xy, ha='center', textcoords='offset points', xytext=(0, 8))
def _get_transform_matrix( shape: BaseGeometry, params: _TargetTransformParams) -> TransformMatrix: """ previous optimization is toggled with a given geometry, this function will release this toggle :param shape: a shape which the transformation toggled with :param params: params that toggle with the shape :return: transformMatrix elements """ translated = translate(shape, xoff=params.x_offset, yoff=params.y_offset) scaled = scale(translated, xfact=params.scale, yfact=params.scale) scale_origin = interpret_origin(translated, "center", 2) rotate_origin = interpret_origin(scaled, "center", 2) p00 = Point(0, 0) p10 = Point(1, 0) p01 = Point(0, 1) p00_translated = translate(p00, xoff=params.x_offset, yoff=params.y_offset) p00_scaled = scale(p00_translated, xfact=params.scale, yfact=params.scale, origin=scale_origin) p00_rotated = rotate(p00_scaled, angle=params.angle, origin=rotate_origin) # type: Point p01_translated = translate(p01, xoff=params.x_offset, yoff=params.y_offset) p01_scaled = scale(p01_translated, xfact=params.scale, yfact=params.scale, origin=scale_origin) p01_rotated = rotate(p01_scaled, angle=params.angle, origin=rotate_origin) # type: Point p10_translated = translate(p10, xoff=params.x_offset, yoff=params.y_offset) p10_scaled = scale(p10_translated, xfact=params.scale, yfact=params.scale, origin=scale_origin) p10_rotated = rotate(p10_scaled, angle=params.angle, origin=rotate_origin) # type: Point c = p00_rotated.x f = p00_rotated.y a = p10_rotated.x - c d = p10_rotated.y - f b = p01_rotated.x - c e = p01_rotated.y - f return TransformMatrix(a, b, d, e, c, f)