Skip to content

Commit ef7b1df

Browse files
committed
Add magnitude to vector
1 parent e013920 commit ef7b1df

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lgsvl/geometry.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44
# This software contains code licensed as described in LICENSE.
55
#
6+
from math import sqrt
67

78
class Vector:
89
def __init__(self, x = 0.0, y = 0.0, z = 0.0):
@@ -47,6 +48,9 @@ def __mul__(self, v):
4748
def __rmul__(self, v):
4849
return self * v
4950

51+
def magnitude(self):
52+
return sqrt(self.x**2 + self.y**2 + self.z**2)
53+
5054
class BoundingBox:
5155
def __init__(self, min, max):
5256
self.min = min

0 commit comments

Comments
 (0)