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.

github lkesteloot / lathser / vector.py View on Github external
def rotatex90(self):
        return Vector3(self.x, -self.z, self.y)
github lkesteloot / lathser / vector.py View on Github external
def __div__(self, other):
        return Vector3(self.x/other, self.y/other, self.z/other)
github lkesteloot / lathser / outline.py View on Github external
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)
github lkesteloot / lathser / outline.py View on Github external
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)
github lkesteloot / lathser / vector.py View on Github external
def __sub__(self, other):
        return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
github lkesteloot / lathser / vector.py View on Github external
def min(self, other):
        return Vector3(min(self.x, other.x), min(self.y, other.y), min(self.z, other.z))
github lkesteloot / lathser / vector.py View on Github external
def __mul__(self, other):
        return Vector3(self.x*other, self.y*other, self.z*other)
github lkesteloot / lathser / outline.py View on Github external
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
github lkesteloot / lathser / vector.py View on Github external
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)
github lkesteloot / lathser / outline.py View on Github external
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)