Some refactor and tried to figure out the angles right
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import time
|
||||
import math
|
||||
|
||||
# Solar module for simulation of world
|
||||
import objects.solar as solar # Modeling of the world
|
||||
|
||||
from objects.motor import Motor # Small helper functions and constants
|
||||
from objects.board import Board
|
||||
|
||||
STEP = 10
|
||||
@@ -20,8 +18,8 @@ source = solar.Source(world, pos=(0, 50, 0))
|
||||
target = solar.Target(world, pos=(0, 50, 0))
|
||||
|
||||
# Create mirrors in a 3x2 grid
|
||||
for x in range(4):
|
||||
for y in range(2):
|
||||
for x in range(2):
|
||||
for y in range(1):
|
||||
mirror = solar.Mirror(world, cluster_x=x, cluster_y=y)
|
||||
world.add_mirror(mirror)
|
||||
|
||||
@@ -29,21 +27,27 @@ world.update_mirrors_from_source_target(source, target)
|
||||
|
||||
def print_status():
|
||||
for i, mirror in enumerate(world.mirrors):
|
||||
pitch, yaw = mirror.get_angles()
|
||||
print(f"Mirror {i} ({mirror.cluster_x}, {mirror.cluster_y}) angles -> pitch: {pitch:.2f}°, yaw: {yaw:.2f}°")
|
||||
phi, theta = mirror.get_angles()
|
||||
print(f"Mirror {i} ({mirror.cluster_x}, {mirror.cluster_y}) angles -> phi: {phi:.2f}°, theta: {theta:.2f}°")
|
||||
|
||||
print_status()
|
||||
|
||||
a = 1
|
||||
t = time.time()
|
||||
|
||||
world.mirrors[0].phi.set_angle(180)
|
||||
world.mirrors[0].theta.set_angle(180)
|
||||
world.mirrors[1].phi.set_angle(0)
|
||||
world.mirrors[1].theta.set_angle(0)
|
||||
|
||||
print_status()
|
||||
|
||||
# Main
|
||||
try:
|
||||
while True:
|
||||
source.move(0, 0, 0.1)
|
||||
#source.move(0, 0, 0.5)
|
||||
#source.move(10 * math.sin(a * t), 10 * math.cos(a * t))
|
||||
print(source.pos)
|
||||
print(target.pos)
|
||||
#print(source.pos)
|
||||
#print(target.pos)
|
||||
|
||||
world.update_mirrors_from_source_target(source, target)
|
||||
print_status()
|
||||
|
||||
Reference in New Issue
Block a user