summer_course_2024/city_model_structure/attributes/plane.py

58 lines
1.2 KiB
Python
Raw Normal View History

"""
Plane module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from typing import TypeVar
import numpy as np
Point = TypeVar('Point')
class Plane:
"""
Plane class
"""
def __init__(self, origin=None, normal=None):
# todo: other options to define the plane:
# by two lines
# by three points
self._origin = origin
self._normal = normal
self._opposite_normal = None
@property
def origin(self) -> Point:
"""
Get plane origin point
:return: Point
"""
if self._origin is None:
raise NotImplementedError
return self._origin
@property
def normal(self):
"""
Get plane normal [x, y, z]
:return: np.ndarray
"""
if self._normal is None:
raise NotImplementedError
return self._normal
@property
def opposite_normal(self):
"""
get plane normal in the opposite direction [x, y, z]
:return: np.ndarray
"""
if self._opposite_normal is None:
coordinates = []
for coordinate in self.normal:
coordinates.append(-coordinate)
self._opposite_normal = np.array(coordinates)
return self._opposite_normal