An edge on medial mesh : , where represents a sphere with the center at and radius of .
Compute
Firstly, we need to compute angle : where . Then we need to adjust according to and to ensure that it is between 0 and : if , should be .
Start direction
Before computing , we should choose a start direction . First, let be , then we check whether is parallel to . If they are parallel, we pick a new direction . Finally, we correct to make it perpendicular to : and normalize it.
Now we can compute as
Construct conical surface
To construct a conical surface, we can rotate around with as starting point and generate . Assume the resolution of the conical surface is . For i-th rotation where is the rotation matrix with a rotation angle of : Check this link for the detailed derivation.
Triangle faces
We add all into an array and it should be like . To connect vertices into triangles, the order should be , where . And do not forget to connect the surface by adding triangle .
Result (Resolution : 64)
Medial Slab Generation
A triangle face on medial mesh: . (red) is the final tangent point we want. For medial sphere , should be the intersection point of two conical surfaces and . The illustration is shown below.
Algorithm
First, compute normal vector of the triangle face: Then, in order to get the intersection point of two conical surfaces, we need to calculate and in the same way as before. Assume is the projection of on , and are the vertical feet of on and respectively. So, base on triangle similarity, or is computed as: where is the radius of the .
should be the intersection point of line with face . So, we can rotate 90 degrees around at to get .(The rotation matrix is same as before.) And can be expressed as normal and point . With simple plane-line intersection test, we can get . So is:
The final result is symmetrical intersection points:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# compute the intersect points of medial cone:{v1,v2} and medial cone:{v1,v3} on sphere (v1,r1) defintersect_point_of_cones(v1, r1, v2, r2, v3, r3, norm): v12 = v2 - v1 phi_12 = compute_angle(r1, r2, v12)