2021-06-23 09:53:33 -04:00
|
|
|
"""
|
|
|
|
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:
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get plane origin point
|
|
|
|
:return: Point
|
2021-06-23 09:53:33 -04:00
|
|
|
"""
|
|
|
|
if self._origin is None:
|
|
|
|
raise NotImplementedError
|
|
|
|
return self._origin
|
|
|
|
|
|
|
|
@property
|
|
|
|
def normal(self):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get plane normal [x, y, z]
|
|
|
|
:return: np.ndarray
|
2021-06-23 09:53:33 -04:00
|
|
|
"""
|
|
|
|
if self._normal is None:
|
|
|
|
raise NotImplementedError
|
|
|
|
return self._normal
|
|
|
|
|
|
|
|
@property
|
|
|
|
def opposite_normal(self):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
get plane normal in the opposite direction [x, y, z]
|
|
|
|
:return: np.ndarray
|
2021-06-23 09:53:33 -04:00
|
|
|
"""
|
|
|
|
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
|