1 | initial version |
For example:
O = vector((0, 0))
Tp = vector((1, 0))
Np = vector((0, 1))
scene = [[Tp,Np],[Tp+Np,-Np]]
alpha = pi/6
R = matrix(2,2,[cos(alpha),-sin(alpha),sin(alpha),cos(alpha)])
p = Graphics()
for obj in scene:
p += sum([plot(v) for v in obj])
p += sum([plot(R*v,color='red') for v in obj])
p.show(axes=False, aspect_ratio=1)
2 | No.2 Revision |
For example:
O = vector((0, 0))
Tp = vector((1, 0))
Np = vector((0, 1))
scene = [[Tp,Np],[Tp+Np,-Np]]
alpha = pi/6
R = matrix(2,2,[cos(alpha),-sin(alpha),sin(alpha),cos(alpha)])
p = Graphics()
for obj in scene:
p += sum([plot(v) for v in obj])
p += sum([plot(R*v,color='red') for v in obj])
p.show(axes=False, aspect_ratio=1)
Supplement: You can use PIL to rotate an entire plot. PIL is included in Sage.
P1 = plot(x^2,-2,2,thickness=2)
P1.save('./data/test1.png',xmin=-2,xmax=2,ymin=-2,ymax=2,axes=False)
P2 = point((0,0),color='black',transparent=True) # a dummy plot to draw the axes
P2.save('./data/test2.png',xmin=-2,xmax=2,ymin=-2,ymax=2)
from PIL import Image
background = Image.open(DATA+"test2.png")
overlay = Image.open(DATA+"test1.png")
overlay = overlay.rotate(-45).resize(background.size)
new_img = Image.blend(background, overlay, 0.7)
new_img.save("new.png")