Interpolated Medial Axis Transform Mesh Generation

Detailed algorithm in blender-mat-addon

Medial Cone Generation

An edge on medial mesh : , where represents a sphere with the center at and radius of .

cone_illustration

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

slab_illustration 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)
def intersect_point_of_cones(v1, r1, v2, r2, v3, r3, norm):
v12 = v2 - v1
phi_12 = compute_angle(r1, r2, v12)

v13 = v3 - v1
phi_13 = compute_angle(r1, r3, v13)

p12 = v1 + normalize(v12) * np.cos(phi_12) * r1
p13 = v1 + normalize(v13) * np.cos(phi_13) * r1
mat = rotate_mat(p12, v12, np.pi / 2)
dir_12 = mat.dot(np.append(norm, [0]))[:3]
intersect_p = plane_line_intersection(v13, p13, dir_12, p12)

v1p = intersect_p - v1
scaled_n = np.sqrt(max(r1 * r1 - np.dot(v1p, v1p), 1e-5)) * norm
return [intersect_p + scaled_n, intersect_p - scaled_n]

Results

Slab faces are outlined.