rename units to scale for the size of the world

This commit is contained in:
Pim Nelissen
2026-01-27 21:09:13 +01:00
parent 7a03251c6f
commit 5a7c2338f3

View File

@ -6,7 +6,12 @@ from pg_rad.path import Path
from pg_rad.objects import Source from pg_rad.objects import Source
class Landscape: class Landscape:
def __init__(self, size: int | tuple[int, int, int] = 500, unit = 'meters'): def __init__(
self,
size: int | tuple[int, int, int] = 500,
scale = 'meters',
):
if isinstance(size, int): if isinstance(size, int):
self.world = np.zeros((size, size, size)) self.world = np.zeros((size, size, size))
elif isinstance(size, tuple) and len(size) == 3: elif isinstance(size, tuple) and len(size) == 3:
@ -14,7 +19,7 @@ class Landscape:
else: else:
raise TypeError("size must be an integer or a tuple of 3 integers.") raise TypeError("size must be an integer or a tuple of 3 integers.")
self.unit = unit self.scale = scale
self.path: Path = None self.path: Path = None
self.sources: list[Source] = [] self.sources: list[Source] = []
@ -33,8 +38,8 @@ class Landscape:
fig, ax = plt.subplots() fig, ax = plt.subplots()
ax.set_xlim(right=x_lim) ax.set_xlim(right=x_lim)
ax.set_ylim(top=y_lim) ax.set_ylim(top=y_lim)
ax.set_xlabel(f"X [{self.unit}]") ax.set_xlabel(f"X [{self.scale}]")
ax.set_ylabel(f"Y [{self.unit}]") ax.set_ylabel(f"Y [{self.scale}]")
if not self.path == None: if not self.path == None:
ax.plot(self.path.x_list, self.path.y_list, 'bo-') ax.plot(self.path.x_list, self.path.y_list, 'bo-')