def processRingSection(self, sectionOrderWidget, number): sortedDevices = sectionOrderWidget.getSortedDevices() deviceNumber = 0 baseAngle = (360.0 / len(self.deviceOrderWidgets)) * number for device in sortedDevices: angle = baseAngle + deviceNumber [xCoord, yCoord] = ArcDrawingTools.polarToCartesian(0, 0, 1, angle) device.realCoordinates = [float(xCoord), float(yCoord)] self.tDeviceManager.putDeviceParametersIntoDb(device) deviceNumber -= 1
def testPolarToCartesian(self): self.assertEqual(ArcDrawingTools.polarToCartesian(2005, 1500, 600, 95), [2602.716818855047, 1552.2934456485948]) self.assertEqual(ArcDrawingTools.polarToCartesian(20, 30, 10, 180), [20.0, 40.0])