Some refactor and tried to figure out the angles right

This commit is contained in:
2026-01-15 15:25:06 +01:00
parent dc349ff68d
commit cc3371b73b
6 changed files with 59 additions and 180 deletions

25
objects/generic.py Normal file
View File

@@ -0,0 +1,25 @@
import numpy as np
class MovingEntity:
"""Embedded entity in the world with a position."""
def __init__(self, world):
self.world = world
self.pos = np.array((0.0, 0.0, 0.0)) # (x, y, z) in local untilted coordinates
def get_pos_rotated(self):
"""Return position rotated by world's tilt around y-axis."""
return self.world.rotate_point_y(self.pos)
def move(self, dx=0, dy=0, dz=0):
self.pos = (self.pos[0] + dx, self.pos[1] + dy, self.pos[2] + dz)
class Target(MovingEntity):
def __init__(self, world, pos=(0.0, 0.0, 0.0)):
super().__init__(world)
self.pos = np.array(pos) # Store everything in numpy
class Source(MovingEntity):
def __init__(self, world, pos=(10.0, 10.0, 10.0)):
super().__init__(world)
self.pos = np.array(pos)