Why write this software
Friends engaged in measurement work often use the method of forward rendezvous for measurement, and the later data processing of forward rendezvous will involve complex calculation formulas, which is cumbersome, laborious and error prone. Why not write a user-oriented "fool" software in half an hour?
The first step is to design the software interface
My principle is to be concise and practical, not fancy, not bloated, simple and rough. Being straightforward is my principle, so the software interface came into being.
Function 1: data example
This function mainly tells the user what format the source file needs to be imported by the software. For the convenience of the user, click the "data example" button, and the software will directly output the data example in Excel format to the user's C disk. The user can directly modify and input his own data on the example to import the software for calculation.
Function 2: import data
As the name suggests, this function is to import the original data into the software on the basis of editing the original data in the first step.
Function 3: Calculation
Click the calculate button, the software will directly display the calculation process and results in the textBrowser and tablewidget, and also compare the calculation results with the tolerance to display the accuracy of the calculation results. The results within the tolerance will display green, and the results beyond the tolerance will display red. This detail is worth calling Call
Function 4: mesh drawing
This function is to use matplotlib to draw the network diagram of forward intersection in real time according to the relative position of the actual point coordinates for reference. (the quality of the mesh will also affect the accuracy of the image results)
Function 5: output results
This function is to export the calculation results. The data result format is consistent with the original data format, which will not be repeated here.
Function 6: screen clearing
This function is to initialize the software. There is no need to repeat it.
Core code
Conversion of degrees, minutes and seconds to radian code
def num2deg(self,num): numstr = str(num) idx = numstr.find('.') deg = int(numstr[:idx]) mnt = int(numstr[idx + 1:idx + 3]) / 60.0 sec = int(numstr[idx + 3:]) / 100 / 3600.0 deg = deg + mnt + sec return deg
Forward intersection algorithm code
a1 = math.radians(self.num2deg(a1)) b1 = math.radians(self.num2deg(b1)) cot = 1 / math.tan(a1) + 1 / math.tan(b1) xp1 = ((xa / math.tan(b1)) + (xb / math.tan(a1)) + (yb - ya)) / cot yp1 = ((ya / math.tan(b1)) + (yb / math.tan(a1)) - (xb - xa)) / cot a2 = math.radians(self.num2deg(a2)) b2 = math.radians(self.num2deg(b2)) cot = 1 / math.tan(a2) + 1 / math.tan(b2) xp2 = ((xb /math.tan(b2)) +(xc /math.tan(a2)) + (yc - yb))/cot yp2 = ((yb / math.tan(b2)) + (yc / math.tan(a2)) - (xc - xb)) / cot xp = (xp1 + xp2) / 2 yp = (yp1 + yp2) / 2 xp = round(xp, 3) yp = round(yp, 3) dap = ((xa - xp) * (xa - xp) + (ya - yp) * (ya - yp)) ** 0.5 v_a = math.radians(self.num2deg(v_a)) hp1 = ha + dap * math.tan(v_a) + ha_yiqi - ha_lengjing dbp = ((xb - xp) * (xb - xp) + (yb - yp) * (yb - yp)) ** 0.5 v_b = math.radians(self.num2deg(v_b)) hp2 = hb + dbp * math.tan(v_b) + hb_yiqi - hb_lengjing dcp = ((xc - xp) * (xc - xp) + (yc - yp) * (yc - yp)) ** 0.5 v_c = math.radians(self.num2deg(v_c)) - hc_lengjing hp3 = hc + dcp * math.tan(v_c) + hc_yiqi hp = (hp1 + hp2 + hp3) / 3 hp = round(hp, 3) Dx = abs(xp1 - xp2) Dy = abs(yp1 - yp2) Dh = abs((hp1 - hp2)+(hp1 - hp3)+(hp2 - hp3)) Dx = round(Dx,3) Dy = round(Dy, 3) Dh = round(Dh, 3)
The above codes have been checked by a large number of actual data, and the results are highly consistent with the manual calculation results. You can rest assured to use them.