-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.uconn.edu/tjs20011/SDP-37-Model
- Loading branch information
Showing
27 changed files
with
869 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from .auv import ( | ||
AUV, | ||
AUVPath, | ||
AUVPathGen | ||
AUV as AUV, | ||
AUVPath as AUVPath, | ||
AUVPathGen as AUVPathGen, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from .custom_np import CustomNP as CustomNP | ||
from .custom_types import ( | ||
Vector3 as Vector3, | ||
Triangle as Triangle, | ||
Ray as Ray, | ||
) | ||
from .custom_arrays import ( | ||
FloatArray as FloatArray, | ||
TriangleArray as TriangleArray, | ||
Vector3Array as Vector3Array, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from typing import Any, Iterable, Literal, overload | ||
import numpy as np | ||
|
||
from . import CustomNP, Triangle, Vector3 | ||
|
||
class FloatArray(CustomNP): | ||
def __new__(cls, | ||
content: Iterable[float]|np.ndarray|None = None, | ||
): | ||
if isinstance(content, np.ndarray): | ||
if content.ndim != 1: raise ValueError(content.shape) # must be 1d | ||
return content.view(cls) | ||
if content is None: | ||
return np.ndarray((0,), float).view(cls) | ||
return np.array(content).view(cls) | ||
def __getitem__(self, index): | ||
if isinstance(index, slice): return super().__getitem__(index).view(type(self)) | ||
return super().__getitem__(index) | ||
|
||
class Vector3Array(CustomNP): | ||
def __new__(cls, | ||
content: Iterable[Vector3]|np.ndarray|None = None, | ||
): | ||
if isinstance(content, np.ndarray): | ||
if content.ndim == 1: content = content.reshape((1,) + content.shape) | ||
if content.ndim != 2: raise ValueError(content.shape) # must be 1d or 2d | ||
if content.shape[1] != 3: raise ValueError(content.shape) # must be shape (n, 3) | ||
return content.view(cls) | ||
if content is None: | ||
return np.ndarray((0, 3), float).view(cls) | ||
return np.array(content).view(cls) | ||
def __getitem__(self, index): | ||
if isinstance(index, slice): return super().__getitem__(index).view(type(self)) | ||
return super().__getitem__(index) | ||
|
||
class TriangleArray(CustomNP): | ||
def __new__(cls, | ||
content: Iterable[Triangle]|np.ndarray|None = None, | ||
): | ||
if isinstance(content, np.ndarray): | ||
if content.ndim == 2: content = content.reshape((1,) + content.shape) | ||
if content.ndim != 3: raise ValueError(content.shape) # must be 2d or 3d | ||
if content.shape[1] != 3 or content.shape[2] != 3: raise ValueError(content.shape) # must be shape (n, 3, 3) | ||
return content.view(cls) | ||
if content is None: | ||
return np.ndarray((0, 3, 3), float).view(cls) | ||
return np.array(content).view(cls) | ||
def __getitem__(self, index): | ||
if isinstance(index, slice): return super().__getitem__(index).view(type(self)) | ||
return super().__getitem__(index) | ||
@property | ||
def verticies(self) -> tuple[Vector3Array, Vector3Array, Vector3Array]: | ||
v0, v1, v2 = self.swapaxes(0, 1) | ||
return (v0.view(Vector3Array), v1.view(Vector3Array), v2.view(Vector3Array)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import numpy as np | ||
from typing import Any, Iterable, Literal, Self, Type, TypeVar, overload | ||
|
||
from . import CustomNP, Triangle, Vector3 | ||
|
||
class FloatArray(CustomNP[tuple[int, Literal[3]], np.dtype[np.float_]]): | ||
@overload | ||
def __new__(cls) -> FloatArray:... | ||
@overload | ||
def __new__(cls, content: Iterable[float]) -> FloatArray:... | ||
@overload | ||
def __new__(cls, content: np.ndarray[tuple[int], np.dtype[np.float_]]) -> FloatArray:... | ||
|
||
@overload # type: ignore | ||
def __getitem__(self, index:int) -> float: ... | ||
@overload | ||
def __getitem__(self, index:slice) -> Self: ... | ||
|
||
class Vector3Array(CustomNP[tuple[int, Literal[3]], np.dtype[np.float_]]): | ||
@overload | ||
def __new__(cls) -> Vector3Array:... | ||
@overload | ||
def __new__(cls, content: Iterable[Vector3]) -> Vector3Array:... | ||
@overload | ||
def __new__(cls, content: np.ndarray[tuple[int, Literal[3]], np.dtype[np.float_]]) -> Vector3Array:... | ||
|
||
@overload # type: ignore | ||
def __getitem__(self, index:int) -> Vector3: ... | ||
@overload | ||
def __getitem__(self, index:tuple[int, Literal[0, 1, 2]]) -> float: ... | ||
@overload | ||
def __getitem__(self, index:slice) -> Self: ... | ||
|
||
class TriangleArray(CustomNP[tuple[int, Literal[3], Literal[3]], np.dtype[np.float_]]): | ||
@overload | ||
def __new__(cls) -> TriangleArray:... | ||
@overload | ||
def __new__(cls, content: Iterable[Triangle]) -> TriangleArray:... | ||
@overload | ||
def __new__(cls, content: np.ndarray[tuple[int, Literal[3], Literal[3]], np.dtype[np.float_]]) -> TriangleArray:... | ||
|
||
@overload # type: ignore | ||
def __getitem__(self, index:int) -> Triangle: ... | ||
@overload | ||
def __getitem__(self, index:tuple[int, Literal[0, 1, 2]]) -> Vector3: ... | ||
@overload | ||
def __getitem__(self, index:tuple[int, Literal[0, 1, 2], Literal[0, 1, 2]]) -> float: ... | ||
@overload | ||
def __getitem__(self, index:slice) -> Self: ... | ||
|
||
@property | ||
def verticies(self) -> tuple[Vector3Array, Vector3Array, Vector3Array]: ... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
from typing import Generic, TypeVar, Self | ||
import numpy as np | ||
|
||
|
||
_S = TypeVar('_S', bound=tuple) | ||
_T = TypeVar('_T', bound=np.dtype) | ||
class CustomNP(np.ndarray[_S, _T]): | ||
def __add__(self, other): | ||
return super().__add__(other).view(type(self)) | ||
def __sub__(self, other): | ||
return super().__sub__(other).view(type(self)) | ||
def __mul__(self, other): | ||
return super().__mul__(other).view(type(self)) | ||
def __truediv__(self, other): | ||
return super().__truediv__(other).view(type(self)) | ||
def __rtruediv__(self, other): | ||
return super().__rtruediv__(other).view(type(self)) | ||
@property | ||
def nd(self): | ||
return self.view(np.ndarray) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from typing import TypeVar, Self | ||
import numpy as np | ||
|
||
|
||
_S = TypeVar('_S', bound=tuple) | ||
_T = TypeVar('_T', bound=np.dtype) | ||
class CustomNP(np.ndarray[_S, _T]): | ||
def __add__(self, other:Self) -> Self: ... # type: ignore | ||
def __sub__(self, other:Self) -> Self: ... # type: ignore | ||
def __mul__(self, other:Self|float) -> Self: ... # type: ignore | ||
def __truediv__(self, other:Self|float) -> Self: ... # type: ignore | ||
def __rtruediv__(self, other:float) -> Self: ... # type: ignore | ||
|
||
@property | ||
def nd(self) -> np.ndarray: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from typing import Any, Iterable, Literal, Self, overload | ||
import numpy as np | ||
from . import CustomNP | ||
|
||
class Vector3(CustomNP): | ||
def __new__(cls, | ||
x: float | tuple[float, float, float] | Self, y = 0, z = 0): | ||
if isinstance(x, tuple): | ||
x, y, z = x | ||
elif isinstance(x, Vector3): | ||
x, y, z = x | ||
assert isinstance(x, (float, int, np.floating)) | ||
return np.array([x, y, z]).view(cls) | ||
def __str__(self): | ||
return f"({self[0]}, {self[1]}, {self[2]})" | ||
def __repr__(self): | ||
return f"Vector3({self[0]}, {self[1]}, {self[2]})" | ||
|
||
class Triangle(CustomNP): | ||
def __new__(cls, | ||
v0: Vector3 | tuple[Vector3, Vector3, Vector3], | ||
v1: Vector3 = Vector3(0, 0, 0), | ||
v2: Vector3 = Vector3(0, 0, 0), | ||
) -> 'Triangle': | ||
if isinstance(v0, tuple): | ||
v0, v1, v2 = v0 | ||
return np.array([v0, v1, v2]).view(cls) | ||
|
||
def __str__(self) -> str: | ||
return f"({self[0]}, {self[1]}, {self[2]})" | ||
def __repr__(self) -> str: | ||
return f"Vector3({self[0]}, {self[1]}, {self[2]})" | ||
|
||
class Ray: | ||
direction:Vector3 | ||
origin:Vector3 | ||
def __init__(self, | ||
direction:Vector3, | ||
origin:Vector3, | ||
) -> None: | ||
self.direction = direction | ||
self.origin = origin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from typing import Any, Iterable, Iterator, Literal, TypeAlias, TypeVar, overload | ||
import numpy as np | ||
from . import CustomNP | ||
|
||
class Vector3(CustomNP[tuple[Literal[3]], np.dtype[np.float_]]): | ||
@overload | ||
def __new__(cls, x: float, y: float, z: float) -> Vector3: ... | ||
@overload | ||
def __new__(cls, x: tuple[float, float, float]) -> Vector3: ... | ||
@overload | ||
def __new__(cls, x: Vector3) -> Vector3: ... | ||
|
||
def __getitem__(self, index:Literal[0, 1, 2]) -> float: ... # type: ignore | ||
|
||
class Triangle(CustomNP[tuple[Literal[3], Literal[3]], np.dtype[np.float_]], Iterable[Vector3]): | ||
@overload | ||
def __new__(cls, v0: Vector3, v1: Vector3, v2: Vector3) -> Triangle: ... | ||
@overload | ||
def __new__(cls, v0: tuple[Vector3, Vector3, Vector3]) -> Triangle: ... | ||
@overload | ||
def __new__(cls, v0: Triangle) -> Triangle: ... | ||
|
||
@overload # type: ignore | ||
def __getitem__(self, index:Literal[0, 1, 2]) -> Vector3: ... | ||
@overload | ||
def __getitem__(self, index:tuple[Literal[0, 1, 2], Literal[0, 1, 2]]) -> float: ... | ||
|
||
def __add__(self, other:Triangle) -> Triangle: ... # type: ignore | ||
def __sub__(self, other:Triangle) -> Triangle: ... # type: ignore | ||
|
||
def __iter__(self) -> Iterator[Vector3]: ... | ||
class Ray: | ||
direction:Vector3 | ||
origin:Vector3 | ||
def __init__(self, | ||
direction:Vector3, | ||
origin:Vector3, | ||
) -> None: | ||
self.direction = direction | ||
self.origin = origin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from .auv import( | ||
place_auvs_over_points as place_auvs_over_points, | ||
generate_paths as generate_paths, | ||
scan_paths as scan_paths, | ||
) | ||
from .hull import ( | ||
generate_hulls as generate_hulls, | ||
generate_points_on_hull as generate_points_on_hull, | ||
generate_vertical_bounds as generate_vertical_bounds, | ||
load_anomalies as load_anomalies, | ||
pick_anomalies as pick_anomalies, | ||
place_anomalies_at_points as place_anomalies_at_points, | ||
) |
Oops, something went wrong.