From 4acc0154a9b8de1279cac9eb3a314e24c8d14b90 Mon Sep 17 00:00:00 2001 From: JoeBell Date: Sun, 9 Mar 2025 18:00:03 -0400 Subject: [PATCH] Added normalize function Added function to normalize the scale of meshes --- ShipGen/Generate.py | 4 ++++ ShipGen/__init__.py | 1 + 2 files changed, 5 insertions(+) diff --git a/ShipGen/Generate.py b/ShipGen/Generate.py index bd067e7..321ce90 100644 --- a/ShipGen/Generate.py +++ b/ShipGen/Generate.py @@ -82,6 +82,10 @@ def mesh_to_triangles(mesh:Mesh) -> np.ndarray: def mesh_list_to_triangles(mesh_list:list[Mesh]) -> list[np.ndarray]: return list(map(mesh_to_triangles, mesh_list)) +def normalize_x(mesh:Mesh, scale:float = 10): + mesh.vectors -= np.array([mesh.min_[0], 0, 0]) + mesh.vectors *= scale / (mesh.max_[0] - mesh.min_[0]) + def load_data(): # Load in the Data: diff --git a/ShipGen/__init__.py b/ShipGen/__init__.py index 46692fc..1d07d5d 100644 --- a/ShipGen/__init__.py +++ b/ShipGen/__init__.py @@ -3,4 +3,5 @@ ShipCharacteristics, mesh_to_triangles, mesh_list_to_triangles, + normalize_x, ) \ No newline at end of file