26 lines
831 B
Python
26 lines
831 B
Python
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)
|