add logging and main function to fancymath
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
"""This module defines the Vector class. """
|
||||
|
||||
import logging
|
||||
from math import acos, sqrt
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Vector(object):
|
||||
def __init__(self, x, y, z):
|
||||
"""Constructor method."""
|
||||
@@ -12,6 +15,9 @@ class Vector(object):
|
||||
|
||||
def dot(self, v):
|
||||
"""Returns the dot product with Vector *v*."""
|
||||
if not isinstance(v, self.__class__):
|
||||
logger.error(f"Expected an instance of {self.__class__}, but got {type(v)} instead.")
|
||||
return None
|
||||
d = self.x * v.x + self.y * v.y + self.z * v.z
|
||||
return d
|
||||
|
||||
|
||||
Reference in New Issue
Block a user