m[1][0] = sinTheta m[1][1] = cosTheta return m def mat_pt_list(m, ptList): """ transform the entire ptList """ return [mat_vec(m, v) for v in ptList] """ Begin testing ... """ width = 800 height = 600 td.create_plot(width, height, True) pts, sizes, colors = getMyFace() td.plot_points(pts, sizes, colors) input("A: Show the basic plot, <CR> to continue") input("\nB: Mat_Mat Test: Scale first then rotate in 30 steps") for i in range(0, 60, 2): td.clear_plot(True) r = rotate_mat(i) sx = 1 + i/2 * 0.01 sy = 1 - 0.01 * i/2 s = scale_mat(sx, sy) print(f" scale: ({sx:3.2f}, {sy:3.2f}) then rotate:{i:2}") cm = mat_mat(r, s) td.plot_points(mat_pt_list(cm, myface_pt_list()), sizes, colors)
import sys sys.path.append('./Lib') # this is where all the library files are import math import turtle_draw as td import MyFace as mf """ Matrix Utilities """ def dot_vector(v1, v2): return sum(a * b for a, b in zip(v1, v2)) """ Begin drawing """ print() print("Simple face plot with axis") w = 800 h = 600 td.create_plot(w, h, True) # show the axis ptList, sizeList, colorList = mf.getMyFace() td.plot_points(ptList, sizeList, colorList) def f(x, y): print("Left Mouse click: x, y)") td.turtle_draw_mouse_click(f, 1)