# How to use the vector.Vector3 function in vector

## To help you get started, weβve selected a few vector examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

lkesteloot / lathser / vector.py View on Github
def rotatex90(self):
return Vector3(self.x, -self.z, self.y)
lkesteloot / lathser / vector.py View on Github
def __div__(self, other):
return Vector3(self.x/other, self.y/other, self.z/other)
lkesteloot / lathser / outline.py View on Github
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)
lkesteloot / lathser / outline.py View on Github
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)
lkesteloot / lathser / vector.py View on Github
def __sub__(self, other):
return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
lkesteloot / lathser / vector.py View on Github
def min(self, other):
return Vector3(min(self.x, other.x), min(self.y, other.y), min(self.z, other.z))
lkesteloot / lathser / vector.py View on Github
def __mul__(self, other):
return Vector3(self.x*other, self.y*other, self.z*other)
lkesteloot / lathser / outline.py View on Github
def loadFile(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
lkesteloot / lathser / vector.py View on Github
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)
lkesteloot / lathser / outline.py View on Github
bbox3d = BoundingBox3D()
for triangle in triangles:

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")

index = 0
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)

## vector

Vector classes and utilities

BSD-3-Clause