def project3Dto2D(p3list): v01 = Vector3((p3list[1][0] - p3list[0][0]), (p3list[1][1] - p3list[0][1]), (p3list[1][2] - p3list[0][2])) v12 = Vector3((p3list[2][0] - p3list[1][0]), (p3list[2][1] - p3list[1][1]), (p3list[2][2] - p3list[1][2])) vn = pgl.cross(v01, v12) p2s = [] # cosTheta = A dot B/(|A|*|B|) => if A dot B ==0, then Theta == 90 # if polygon not || y axis, project it to the y=0 plane if pgl.dot(vn, Vector3(0, 1, 0)) != 0: for i in range(len(p3list)): v = p3list[i][0], p3list[i][2] p2s.append(v) else: # if polygon || y axis and z axis (it will perpendicular x axis), project it to the x=0 plane # if polygon || y axis and x axis (it will perpendicular z axis), project it to the z=0 plane # if polygon || y axis, not || x and z (it will not perpendicular z and x # axis), project it to the z=0 plane (or x=0 plane) if pgl.dot(vn, Vector3(0, 0, 1)) == 0: for i in range(len(p3list)): v = p3list[i][1], p3list[i][2] p2s.append(v) else: for i in range(len(p3list)): v = p3list[i][0], p3list[i][1] p2s.append(v) return p2s
def transform(v,t_edir): v = (v - m_center) nval = [ pgl.dot(v,ed) for ed in m_edir] nv = sum([val * ed for val, ed in zip(nval, t_edir)],pgl.Vector3(0,0,0)) return (nv + p_center)
def transform(v, t_edir): v = (v - m_center) nval = [pgl.dot(v, ed) for ed in m_edir] nv = sum([val * ed for val, ed in zip(nval, t_edir)], pgl.Vector3(0, 0, 0)) return (nv + p_center)