How to reasonably label the angle of two non-parallel segments. For example, for the following two initial line segments:
Depending on the location of the current mouse, we may obtain the following different annotation methods:
The general idea of self-tagging is: first, find the two endpoints of the arc (dimension line), and then calculate the two endpoints based on the two obtained endpoints, respectively, and calculate the two leads (witness line).
Find the endpoint of an arcAlgorithm:
Let's simplify the problem. For any two intersecting rays, the following uses acute angle as an example (the process of solving the acute angle is completely consistent ):
Take the intersection of the two line segments as the center of the circle, and the distance from the mouse position to the center of the circle as the radius. Draw a circle, and there will be four intersections between the two lines and the circle, the two endpoints of dimension line must be two of the four intersections.
The problem is how to select two vertices from these four intersections as the endpoint of dimension line.
The method is as follows: we use the red solid vector and blue solid vector in the figure above as two reference vectors and divide the image into the following four quadrants:
Then, based on the current mouse position, determine which quadrant should be taken. The practice is to remember value = (Red vector x orange vector). (orange vector x blue vector)
If the obtained value is greater than 0, the current mouse must be in the three quadrant; otherwise, the mouse must be in the second quadrant.
The next step is how to accurately point to the mouse in the First quadrant, or in the Three-image limit. I figured out from the perspective that there should be more efficient and convenient algorithms, but I did not expect them at present.
We can find that, assuming that the current mouse is in the third quadrant, the angle of the orange vector to the two reference vectors respectively (Red solid vector and blue solid vector) must be greater than 180 °, if the obtained angle and less than 180 ° can be determined as the first quadrant. (This method is still applicable to the blunt angle. Considering that the current mouse is in the second quadrant, the red dotted line vector and the blue solid line vector are used as reference vectors)
The algorithm is implemented as follows. The idea is basically the same as above, and only some optimizations are made:
Evaluate the dimensionline endpoint Algorithm 1 Private Void Getdimensionlineendpoints (lineseg3d firstseg3d, lineseg3d secondseg3d, point3d thirdpt, Out Point3d firstcrosspt, Out Point3d secondcrosspt)
2 {
3 Point3d centerpoint = Getintersectpoint (firstseg3d, secondseg3d );
4 Double Radius = Thirdpt. distanceto (centerpoint );
5
6 Vector3d firstlinevec = (Firstseg3d. endpoint - Centerpoint). Normal ();
7 Vector3d secondlinevec = (Secondseg3d. endpoint - Centerpoint). Normal ();
8 Vector3d thirdlinevec = (Thirdpt - Centerpoint). Normal ();
9
10 If (Firstlinevec. crossproduct (thirdlinevec). dotproduct (thirdlinevec. crossproduct (secondlinevec )) < 0 )
11 Secondlinevec = - Secondlinevec;
12
13 If (Thirdlinevec. angleto (firstlinevec) + Thirdlinevec. angleto (secondlinevec )) > Math. Pi)
14 {
15 Firstlinevec = - Firstlinevec;
16 Secondlinevec = - Secondlinevec;
17 }
18
19 Firstcrosspt = Centerpoint + Firstlinevec * Radius;
20 Secondcrosspt = Centerpoint + Secondlinevec * Radius;
21 }
22
Algorithm for Finding the lead endpoint:
The two endpoints of witness line are two of the above four vertices. The combination method depends on the position of the Green Circle relative to the other three vertices. Currently, the solution I have come up with is not ideal, see if you can think of a more convenient and SIMPLE algorithm to describe tomorrow. Please wait for tomorrow's update.
If you have a better tagging algorithm, please do not hesitate to advise!