def getBoxDist(self, boxCoords, absoluteValue=True): boxDistList = [] #top, right, bottom, left TL2Boat = standardcalc.distBetweenTwoCoords(gVars.currentData.gps_coord, boxCoords[0]) #top left to boat TR2Boat = standardcalc.distBetweenTwoCoords(gVars.currentData.gps_coord, boxCoords[1]) #top right to boat BR2Boat = standardcalc.distBetweenTwoCoords(gVars.currentData.gps_coord, boxCoords[2]) #bottom right to boat BL2Boat = standardcalc.distBetweenTwoCoords(gVars.currentData.gps_coord, boxCoords[3]) #bottom left to boat TL2TR = standardcalc.distBetweenTwoCoords(boxCoords[0], boxCoords[1]) #top left to top right TR2BR = standardcalc.distBetweenTwoCoords(boxCoords[1], boxCoords[2]) #top right to bottom right BR2BL = standardcalc.distBetweenTwoCoords(boxCoords[2], boxCoords[3]) #bottom right to bottom left BL2TL = standardcalc.distBetweenTwoCoords(boxCoords[3], boxCoords[0]) #bottom left to top left topLeftAngle = standardcalc.findCosLawAngle(TL2TR, TL2Boat, TR2Boat) topRightAngle = standardcalc.findCosLawAngle(TR2BR, TR2Boat, BR2Boat) botRightAngle = standardcalc.findCosLawAngle(BR2BL, BR2Boat, BL2Boat) botLeftAngle = standardcalc.findCosLawAngle(BL2TL, BL2Boat, TL2Boat) topDist = TL2Boat * math.sin(topLeftAngle) rightDist = TR2Boat * math.sin(topRightAngle) bottomDist = BR2Boat * math.sin(botRightAngle) leftDist = BL2Boat * math.sin(botLeftAngle) if absoluteValue: boxDistList = [abs(topDist), abs(rightDist), abs(bottomDist), abs(leftDist)] else: boxDistList = [topDist, rightDist, bottomDist, leftDist] return boxDistList
def testFindCosLawAngle(self): self.assertEqual(standardcalc.findCosLawAngle(0,1,2),0) self.assertEqual(standardcalc.findCosLawAngle(1,-1,2),0) self.assertEqual((standardcalc.findCosLawAngle(2,3,4) - 104.477) <=0.001, 1)