Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168703
Image: ubuntu2004
# Rotation anticlockwise through angle t def rotate(v,t,show_matrix=False): M= matrix([[cos(t),-sin(t)],[sin(t),cos(t)]]) if show_matrix: return M return M*vector(v) # Reflection through line of angle t from positive x-axis def reflect(v,t,show_matrix=False): M= matrix([[cos(2*t),sin(2*t)],[sin(2*t),-cos(2*t)]]) if show_matrix: return M return M*vector(v)
A= (4,0) B= (4,4) C= (6,3) D= (4,2) points= [A,B,C,D]
# Rotate through 2*pi/3 t= 2*pi/3 points_rot= [rotate(v,t) for v in points] M= rotate(A,t,show_matrix=True) #print M print M.n() print [v.n() for v in point_rot] p= line(points) p+= line(points_rot,color='red') show(p,aspect_ratio=1)
[-0.500000000000000 -0.866025403784439] [ 0.866025403784439 -0.500000000000000] [(-2.00000000000000, 3.46410161513775), (-5.46410161513775, 1.46410161513775), (-5.59807621135332, 3.69615242270663), (-3.73205080756888, 2.46410161513775)]
# Reflect through y=2*x var('x') s= arccos(1/sqrt(5)) #s= pi/3 #print (s*180/pi).n() points_ref= [reflect(v,s) for v in points] N= reflect(A,s,show_matrix=True) #print N print N.n() print [v.n() for v in points_ref] q= plot(2*x,(x,0,4),color='black') q+= line(points) q+= line(points_ref,color='green') show(q,aspect_ratio=1)
[-0.500000000000000 0.866025403784439] [ 0.866025403784439 0.500000000000000] [(-2.00000000000000, 3.46410161513775), (1.46410161513775, 5.46410161513775), (-0.401923788646684, 6.69615242270663), (-0.267949192431123, 4.46410161513775)]
# Rotate then reflect as above points_rr= [reflect(rotate(v,t),s) for v in points] #print N*M print (N*M).n() print [v.n() for v in points_rr] r= plot(2*x,(x,0,4),color='black') r+= line(points) r+= line(points_rr,color='green') show(r,aspect_ratio=1)
[ 1.00000000000000 0.000000000000000] [0.000000000000000 -1.00000000000000] [(4.00000000000000, 0.000000000000000), (4.00000000000000, -4.00000000000000), (6.00000000000000, -3.00000000000000), (4.00000000000000, -2.00000000000000)]