""" hyper-diamond data and simple rotation in 4D """ from math import pi, sin, cos, sqrt radian = 180.0 / pi # vertices4d 24:(w,x,y,z), belongs to tesseract number vertices4d = [[-1.0, 0.0, 0.0, 0.0], # 1,3 [ 1.0, 0.0, 0.0, 0.0], # 1,3 [ 0.0,-1.0, 0.0, 0.0], # 1,3 [ 0.0, 1.0, 0.0, 0.0], # 1,3 [ 0.0, 0.0,-1.0, 0.0], # 1,3 [ 0.0, 0.0, 1.0, 0.0], # 1,3 [ 0.0, 0.0, 0.0,-1.0], # 1,3 [ 0.0, 0.0, 0.0, 1.0], # 1,3 [-0.5,-0.5,-0.5,-0.5], # 1,2 [ 0.5, 0.5, 0.5, 0.5], # 1,2 [-0.5,-0.5, 0.5, 0.5], # 1,2 [ 0.5, 0.5,-0.5,-0.5], # 1,2 [-0.5, 0.5, 0.5,-0.5], # 1,2 [ 0.5,-0.5,-0.5, 0.5], # 1,2 [-0.5, 0.5,-0.5, 0.5], # 1,2 [ 0.5,-0.5, 0.5,-0.5], # 1,2 [-0.5, 0.5, 0.5, 0.5], # 2,3 [ 0.5,-0.5,-0.5,-0.5], # 2,3 [ 0.5,-0.5, 0.5, 0.5], # 2,3 [-0.5, 0.5,-0.5,-0.5], # 2,3 [ 0.5, 0.5,-0.5, 0.5], # 2,3 [-0.5,-0.5, 0.5,-0.5], # 2,3 [ 0.5, 0.5, 0.5,-0.5], # 2,3 [-0.5,-0.5,-0.5, 0.5]] # 2,3 #rotate in plane axis1, axis2 def Rotate(axis1, axis2, angle): angle = angle / radian for v in vertices4d: c1 = v[axis1]*cos (angle) - v[axis2]*sin (angle) c2 = v[axis1]*sin (angle) + v[axis2]*cos (angle) v[axis1], v[axis2] = c1, c2 #4D axes vectors in 3D per_axes = ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)) iso_x0 = sqrt(8.0 / 9.0) iso_x12 = -sqrt(2.0 / 9.0) iso_y1 = sqrt(2.0 / 3.0) iso_y2 = -sqrt(2.0 / 3.0) iso_z012 = -1.0 / 3.0 iso_axes = ((iso_x0, 0.0, iso_z012), (iso_x12, iso_y1, iso_z012), (iso_x12, iso_y2, iso_z012), (0.0, 0.0, 1.0)) axes_colors = ((0.8, 0.8, 0.8), (0.9, 0.1, 0.1), (0.1, 0.9, 0.1), (0.1, 0.1, 1.0)) axes_labels = ("w","x","y","z")