Пример #1
0
def test_initial_conditions():
    test_0 = Angle()
    test_180 = Angle(180)
    test_big = Angle(540)
    assert approx(0) == test_0
    assert approx(180) == test_180
    assert approx(180) == test_big
Пример #2
0
def test_adding_Angles_together():
    test_0 = Angle()
    test_180 = Angle(180)
    test_negative_5 = Angle(-5)
    result = test_0 + test_180
    assert result == 180
    result = test_0 + test_negative_5
    assert result == 355
    result += test_180
    assert result == 175
Пример #3
0
 def __init__(self):
     self.azimuth = Angle()
     self.elevation = Angle(0, 180)
     self.base_correction = Angle(0, 180)
     self.arm_correction = Angle(0, 180)
     self.last_grav = (0, 0)
     self.compass = Compass()
     self.N_correction = 0
     self.declination = 0
     # self.set_true_north() # not needed as check grav is forced
     self.check_gravity(True)
Пример #4
0
 def check_gravity(self, forced=False):
     changed = self.compass.check_gravity()
     if changed or forced:
         n_az, n_elev, garbage = self.compass.get_correction()
         self.set_true_north()
         self.last_grav = (n_az, n_elev)
         self.arm_correction = Angle(0,180)
         self.arm_correction += n_elev
Пример #5
0
 def set_true_north(self):
     self.N_correction = -1 * self.compass.N_correct
     # N correction is measured relative to the device
     self.declination = self.compass.declination
     # Declination is measured in degrees CW from magnetic north
     # to point to true north
     self.base_correction = Angle(0, 180)
     self.base_correction += self.N_correction
     self.base_correction += self.declination
Пример #6
0
    def elevation_add(self, angle):
        angle = float(angle)  # don't worry if you are passed a string number
        total = self.elevation + angle

        if 270 > total > 90:  # Seperate out the angle change from the rotation mechanics
            self.azimuth_add(180)

        if 180 > total > 90:
            print("{0:5.3f} and {1:5.3f} are greater than 90 when added together".format(float(self.elevation), angle))
            print(total)
            leftover = total - 90
            self.elevation = Angle(90 - leftover, 180)
        elif 270 > total > 180:
            print("{0:5.3f} and {1:5.3f} are less than -90 when added together".format(self.elevation, angle))
            leftover = total + 180
            self.elevation = Angle(360 - leftover, 180)
        else:
            self.elevation += angle
Пример #7
0
 def elevation_set(self, angle):
     angle = float(angle)  # don't worry if you are passed a string number
     self.elevation = Angle(angle, 180)
     self.elevation_add(self.arm_correction)
Пример #8
0
 def azimuth_set(self, angle):
     angle = float(angle)  # don't worry if you are passed a string number
     self.azimuth = Angle(angle)
     self.azimuth_add(self.base_correction.angle)
Пример #9
0
def test_addition_and_subtraction():
    test = Angle()
    assert (test + 5) == 5  # angles add
    assert (test + 365) == 5  # angles overflow when adding
    assert (test - 5) == 355  # angles underflow when subtracting
    assert (test + -5) == 355  # angles underflow when adding a negative