Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def rotatex90(self):
return Vector3(self.x, -self.z, self.y)
def __div__(self, other):
return Vector3(self.x/other, self.y/other, self.z/other)
def __init__(self):
self.min = Vector3(sys.float_info.max, sys.float_info.max, sys.float_info.max)
self.max = Vector3(-sys.float_info.max, -sys.float_info.max, -sys.float_info.max)
def __init__(self):
self.min = Vector3(sys.float_info.max, sys.float_info.max, sys.float_info.max)
self.max = Vector3(-sys.float_info.max, -sys.float_info.max, -sys.float_info.max)
def __sub__(self, other):
return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
def min(self, other):
return Vector3(min(self.x, other.x), min(self.y, other.y), min(self.z, other.z))
def __mul__(self, other):
return Vector3(self.x*other, self.y*other, self.z*other)
def loadFile(filename):
print "Loading model..."
data = json.load(open(filename))
vertices = []
triangles = []
for mesh in data["meshes"]:
rawVertices = mesh["vertices"]
rawNormals = mesh["normals"]
rawFaces = mesh["faces"]
vertexOffset = len(vertices)
vertices.extend([
Vector3(rawVertices[i*3 + 0], rawVertices[i*3 + 1], rawVertices[i*3 + 2])
for i in range(len(rawVertices)/3)])
triangles.extend([Triangle3D([
vertices[vertexOffset + face[0]],
vertices[vertexOffset + face[1]],
vertices[vertexOffset + face[2]]]) for face in rawFaces])
return triangles
def cross(self, other):
a = self
b = other
return Vector3(a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x)
bbox3d = BoundingBox3D()
for triangle in triangles:
bbox3d.addTriangle(triangle)
center = bbox3d.center()
# Move center to origin.
triangles = [triangle - center for triangle in triangles]
# Find scaling factor.
size = bbox3d.size()
max_size = max(size.x, size.y)
scale = MODEL_DIAMETER / max_size * DPI
# Light vector (to light).
light = Vector3(-1, 1, 1).normalized()
all_paths = []
# We write out the theta's in a deep link format. Once we have better file naming
# we could provide a better name than "fromlink" which is only to distinguish it from
# Default.
thetas_file = open("thetas.txt", "w")
thetas_file.write("lathser://sequence/add?name=fromlink")
index = 0
for pass_number, shade_percent in enumerate(PASS_SHADES):
print "------------------ Making pass %d (%d%%)" % (pass_number, shade_percent)
for is_last, angle in identify_last(half_list(angles(ANGLE_COUNT))):
# We append these into a deep link that can be fed into the app.
thetas_file.write("&%g" % angle)