forked from thiago-souzaf/python-ray-tracing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoint.py
More file actions
31 lines (23 loc) · 914 Bytes
/
Copy pathpoint.py
File metadata and controls
31 lines (23 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from vector import Vector
class Point:
"""
Representa um ponto em um espaço tridimensional.
Atributos:
x (float): Componente do ponto no eixo X.
y (float): Componente do ponto no eixo Y.
z (float): Componente do ponto no eixo Z.
"""
def __init__(self, x: float, y: float, z:float):
self.x = x
self.y = y
self.z = z
def __str__(self):
return f"({self.x}, {self.y}, {self.z})"
def __add__(self, point):
return Point(self.x + point.x, self.y + point.y, self.z + point.z)
def __sub__(self, point):
return Vector(self.x - point.x, self.y - point.y, self.z - point.z)
def dot_product(self, point1):
return self.x * point1.x + self.y * point1.y + self.z * point1.z
def distance(self, point):
return ((self.x - point.x) ** 2 + (self.y - point.y) ** 2 + (self.z - point.z) ** 2) ** 0.5