3.2. Definition of Parametric Equation for Torus-like Surfaces
According to
Figure 1, knowing the world coordinates of points
P and
Q and their angle
ξ at point
O, the radius
R of the circular line, with
O1 as the center and
PQ as the chord, and the distance
h from the center
O1 to the chord
PQ can be found:
Figure 1 is just the trajectory of a point O on a plane, and there are countless such planes in world coordinate systems, each of which constructs a segment of arcs with PQ as the chord. These arcs will rotate with PQ as the axes to obtain a rotary body shaped like
Figure 2a.
To facilitate the observation of the position of the view cone in relation to this rotated body, the lower half of it is given in
Figure 2b. We will refer to the surface of this rotated body as the torus-like surface (TLS), where all points on the TLS are the possible solution set of camera position
O.It is easy to see from the generation process that a TLS at any position in the world coordinate system is obtained by rotating an arc around any axis. Taking the PQ axis as an example, its parametric equations are essentially the parametric equations of a spatial circumference with radius h determining the trajectory of the center of the circular arc and determining the size of the arc based on the center of the spatial circumference with radius R.
For the general equation for the spatial circumcircle with the midpoint of the
PQ axis as the center (
xmid,
ymid,
zmid), vector
PQ as the normal vector (
A1,
B1,
C1), and
h as the radius, Equation (5) represents the trajectory obtained by rotating the center of the circle
O1 around the
PQ in
Figure 1:
To facilitate the solution, it needs to be converted into a parametric equation. Let
X =
xO1 −
xmid,
Y =
yO1 −
ymid, and
Z =
zO1 −
zmid for Equation (5). Combining the two equations, the
Z variables and formulas are deformed to obtain Equation (6):
To convert (6) into a more easily computable parametric equation, let
Substituting (7) into (6) yields the parametric equation of
Y with respect to
u. Subsequently, substituting the parametric equations of
X and
Y with respect to
u back into (5) yields the parametric equation of
Z with respect to u. The parametric equations of
X,
Y, and
Z are shown in Equation (8), where 0 ≤
u ≤ 2π:
Ultimately, the parametric equation for
O1, as in
Figure 1, can be obtained as follows:
When both
B1 and
C1 are 0, Equation (9) will fail, and the spatial circumferential parametric equation is converted to the parametric equation of a circular line on the
x =
xmid plane:
The above parametric equation represents the trajectory of the outer circle center O1 rotating around the axis PQ.
Then, take the point
O1 as the center of the circular line,
R as the radius, and cross-multiply the vector
PO1 with the vector
QO1 to obtain the normal vector (
A2,
B2,
C2) to construct the parametric equations of the spatial circumference of the arc, which is also divided into two cases, 0 ≤
v ≤ 2π, when both
B2 and
C2 are not 0:
When both
B2 and
C2 are 0,
Equations (9) and (10), along with Equations (11) and (12), are the four forms of the parametric equations for TLS obtained according to different combinations of each other.
3.3. Solving the Intersection of Three Torus-like Surfaces
Most of the methods for intersecting two curves use tracking method, where the definition of the step size is difficult after the initial position of the intersection point is determined. In order to ensure accurate intersection, the traditional approach is to repeatedly experiment with the optimal step size to adapt to the current surface intersection. However, the sizes of torus-like surfaces change dynamically in application scenarios, so it is obvious that a fixed step size cannot be well adapted to torus-like surface intersection. Different from the traditional methods, this paper adopts a method to intersect torus-like surfaces with an adaptive change of step size according to the characteristics of the torus-like surfaces, which relates the step size to the radius of curvature at the end of the intersecting line, so that the step size can be changed in real time according to the real characteristics of the surfaces. The points on the surface intersection line are fitted with five non-uniform B-spline curves to obtain a higher accuracy of localization.
Four PCs allow the construction of parametric equations for three TLSs at three different locations.
The intersection between two of the parametric TLSs is transformed into a set of parametric curves and a parametric TLS, i.e., the problem is transformed into a problem of intersection between a parametric curve and a parametric surface. Let the two TLSs be P
1 = P
1(
u1,
v1), P
2 = P
2(
u2,
v2). Define a
u-directed parametric curve on P
1 as C(
u), whose equation can be expressed as C(
u) = P
1(
u1,
), where the parameter
indicates that the parameter is fixed.
c0 = P
1(
u10,
) is a point on the parametric line C(
u) of the torus-like surface P
1, and
s0 = P
2(
u20,
v20) is a point on the torus-like surface P
2. The vector distance between
c0 and
s0 is defined as
τ =
c0 −
s0, and an accuracy threshold
ε is set; when |
τ| ≤
ε, it means that the distance between the two points is small enough to be used as the initial value of the intersection. The variable in the parametric line C(
u) = P
1(
u1,
) is u1, and the corresponding variables of surface P
2 are
u2 and
v2, respectively. Let
A Taylor’s formula expansion of τ is obtained by neglecting the higher terms:
Projecting the above equation into normed linear space and dot-multiplying P
1u, P
2u, and P
2v on each side of the equation yields three linear equations:
The above system of three equations in groups does not have a zero denominator or does not converge because the coefficient matrix is positively definite. Substituting
u10 + ∆
u1,
u20 + ∆
u2,
v20 + ∆
v2 into
τ by using Taylor’s formula expansion for the point
c0 and iterating based on the normed linear space projection method [
25] until |
τ| ≤
ε, the initial value of the intersection point is obtained, and whether the intersection point is on the third TLS or not is determined, and if it is, it is saved as a row of intersection candidates.
The next intersection point is solved next, and so on; a series of intersections can be obtained to acquire the whole intersection line. Requirements to take the next intersection are necessary to analyze the point in the space curve of the characteristic parameters.
c0 =
c(
s0) is the curve
c on a point,
s0 is the arc length parameter, and then
c0 neighboring points can have a Taylor expansion expressed as follows:
There are in differential geometry:
In the [
c0,
α0,
β0] coordinate system, defining the point at
c0 as the starting point, there is an arc length parameter of
s0 = 0, step size of Δ
s =
s, and the neighboring points can be expressed as follows:
where
α,
β, and
k are the tangent vectors, principal normal vectors, and curvature of the space curve
c at the point
c0. Based on
α and
β, the close planes can be obtained, which in turn gives the geometric structure of the point
c0 on the space curve [
26]; we can solve for
α,
β, and
k, respectively:
where
n1 and
n2 are the normal vectors at the point
c0;
kn is the normal curvature of each surface at that point obtained from the first and second fundamental forms of the surface;
L,
M, and
N are the coefficients in the second fundamental form; and
k is the curvature vector.
The intersection, which is solved by plugging
α,
β, and
k combined with
s into Equation (18), is an approximation, and at this time, the step size
s is unknown, and if it is set artificially based on experience, the result is not stable and efficient enough, and we found that TLS intersection lines have more obvious curvature changes in different regions. So, we correlate the step-size
s with the radius of curvature at the end of the intersection line according to [
27] so that the step size can be changed in real time based on the real characteristics of the surface; points on the intersection line are fitted using fivefold non-uniform B-spline curve.
where C(
u) is the fivefold non-uniform B-spline curve equation,
u = 1 when the endpoint of C(
u),
r is the radius of curvature on C(
u), and
kr is the curvature of C(
u). When
kr is less than 0, it indicates that the fitted curve curves are bent clockwise along the direction of advancement, and when it is greater than 0, it indicates that it is bent counterclockwise.
e denotes the threshold of accuracy, which is generally taken to be 0.001 mm. The points obtained at this time are not the exact solution, and it is also necessary to iterate to obtain a more accurate value [
28].
In summary, two points closer to the point c(s), denoted as p1 and p2, are firstly selected on the two TLSs P1 and P2, respectively, with p1 belonging to P1 and p2 belonging to P2.
If there is a point p1 and p2 converging to the neighboring point c(s), the point should meet the set accuracy |p1 − p2| ≤ ε. If p1 and p2 cannot converge at the neighboring point, p2 is defined as an approximation of the intersection point. Then, the above computation process is repeated continuously.
If the condition is satisfied, its coordinates need to be substituted into the equation of the third TLS in order to determine whether the point is on this TLS or not. If the distance
d from the midpoint of the axis to the intersection point satisfies the following condition, then
γ is the angle between the vector from the midpoint of the axis to the intersection and the axis vector.
The point is added to the candidate set of intersections. Then, the exact point c(s) found by iteration is used as the initial intersection, and the location of the next intersection continues to be counted until the boundary of the surface is traced.
The approximate process for solving the intersection is as
Figure 3:
The three TLS equations are constructed in such a way as to obtain the circumferential angles ξ1, ξ2, and ξ3, respectively. The angle of circumference ξ1′, ξ2′, and ξ3′ formed by the resulting point of intersection and the two endpoints on the axis, if it satisfies ξ1′ > ξ1 or ξ2′ > ξ2 or ξ3′ > ξ3, shows that the intersection is on the minor arc opposite the axis and should be excluded.
There may be more than one candidate for the intersection, which needs to be filtered according to the normal vectors of the three TLSs’ tangent at the intersection. If the intersection meets the requirements, then it must meet the three TLSs of the visual cone on this intersection overlap, i.e., the upper vector of the three must be at the intersection of the same tangent. Thus, it can be based on the intersection of the tangent surface of the normal vector to determine whether it is colinear or not. If not, then rule out the intersection. In practice, there will still be a very small error, so it is necessary to set a threshold, the normal vector between the two cross-multiplications of the modulus, to do the error evaluation and set it to 1 × 10−11 for the best results after many tests. After filtering, there may still be more than one intersection, so direction vectors should be utilized for further filtering.
3.4. Solving Forward Vector and Upper Vector
The world coordinates of the intersection
O are shown in
Section 3.3, and we can easily obtain the distances of
OP and
OQ. Find the world coordinates
S0 and
S1 of
P,
Q projected on the imaging plane by the proportionality of
OP and
OQ to
Op and
Oq derived in
Section 3.1:
Follow the above equation to find the world coordinates of third point projected on the imaging plane, assumed to be S2.
The forward vector
f is obtained by vector cross-product:
Since these four feature points are ordered beforehand on the image coordinate system according to their positions from top to bottom and left to right, it can be guaranteed that the forward vector is the orientation of the view cone. At the same time, it can be guaranteed that the upper vector of the subsequent solution always points to the camera directly above. If there are still multiple intersection solutions, use whether the angle between OP and f is greater than half of the diagonal viewing angle of the view cone. If it is greater, it means the point is a mirror solution; exclude this type of intersection and leave the intersection with the smallest error as the ultimate solution.
To solve the upper vector based on the front vector, it is also necessary to find a point
T on the centerline
JI on the imaging plane and parallel to the
KN side that is different from the pixel position of point
C. As shown in
Figure 4, select the image coordinate point
p and determine the image coordinates of point
T, whose horizontal coordinate is the abscissa of
p, and the vertical coordinate is the ordinate of
C. In this respect, a right triangle
pTC can be constructed, and
β is found based on the Pythagorean theorem, and then the vector
OT can be obtained from the vector
OS0 rotated around the forward vector
f by an angle
β. The upper vector
u of the camera position point
O can be obtained by cross-multiplying the unit vector of
OT with the forward vector
f.
The TLS solution yields the forward and upward vectors of the camera in the world coordinate system, which can be extrapolated by Rodriguez’s formula to obtain the rotation matrix R. Combined with the intersection coordinate O, the translation vector t is easily obtained.