Implemented the first version of the 3D engine. Added support for loading 'obj' files as a mesh.
This commit is contained in:
+15
@@ -11,6 +11,21 @@ class Vector3d:
|
||||
self.y = y
|
||||
self.z = z
|
||||
|
||||
def cross_product(self, vector3d):
|
||||
# Returns a line that is perpendicular to the parameter
|
||||
# and self.
|
||||
# Returns the 'normal'.
|
||||
x = self.y * vector3d.z - self.z * vector3d.y
|
||||
y = self.z * vector3d.x - self.x * vector3d.z
|
||||
z = self.x * vectored.y - self.y * vector3d.x
|
||||
|
||||
return Vector3d(x, y, z)
|
||||
|
||||
def dot_product(self, vector3d):
|
||||
# Returns a scalar that defines how similar two
|
||||
# vectors are to one another.
|
||||
return self.x * vector3d.x + self.y * vector3d.y + self.z * vector3d.z
|
||||
|
||||
class Vector2d:
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
|
||||
Reference in New Issue
Block a user