simkit.area_normals#
Per-triangle area-weighted normals and their derivatives.
The “area normal” of a triangle is the cross product of two edges; its magnitude is twice the triangle area and its direction is the face normal. These three functions provide the area normal, its gradient with respect to the nine corner coordinates, and its (constant) Hessian.
Functions#
|
Per-triangle area normal |
|
Gradient of the area normal w.r.t. the nine corner coordinates. |
|
Hessian of the area normal w.r.t. the nine corner coordinates. |
Module Contents#
- simkit.area_normals.area_normal_element(x0: numpy.ndarray, x1: numpy.ndarray, x2: numpy.ndarray) numpy.ndarray#
Per-triangle area normal
n = e1 x (-e2).- Parameters:
x0 (np.ndarray (m, 3)) – The three corner positions of each triangle.
x1 (np.ndarray (m, 3)) – The three corner positions of each triangle.
x2 (np.ndarray (m, 3)) – The three corner positions of each triangle.
- Returns:
n – Area normal per triangle;
|n|is twice the triangle area.- Return type:
np.ndarray (m, 3)
- simkit.area_normals.area_normal_gradient_element(x0: numpy.ndarray, x1: numpy.ndarray, x2: numpy.ndarray) numpy.ndarray#
Gradient of the area normal w.r.t. the nine corner coordinates.
Because the area normal is a cross product of edge differences, its derivative w.r.t. each corner is a skew-symmetric (cross-product) matrix of the opposite edge.
- Parameters:
x0 (np.ndarray (m, 3)) – The three corner positions of each triangle.
x1 (np.ndarray (m, 3)) – The three corner positions of each triangle.
x2 (np.ndarray (m, 3)) – The three corner positions of each triangle.
- Returns:
dn_dx – Derivative of the 3-vector normal w.r.t. the stacked corners
[x0, x1, x2].- Return type:
np.ndarray (m, 3, 9)
- simkit.area_normals.area_normal_hessian_element(x0: numpy.ndarray, x1: numpy.ndarray, x2: numpy.ndarray) numpy.ndarray#
Hessian of the area normal w.r.t. the nine corner coordinates.
The area normal is bilinear in the corner positions, so its Hessian is a constant array of 0, +/-1 entries that does not depend on the geometry. It is tiled once per triangle. (The constant block was originally verified by finite differences.)
- Parameters:
x0 (np.ndarray (m, 3)) – The three corner positions of each triangle. Only
x0.shape[0](the triangle count) is used; the values themselves do not matter.x1 (np.ndarray (m, 3)) – The three corner positions of each triangle. Only
x0.shape[0](the triangle count) is used; the values themselves do not matter.x2 (np.ndarray (m, 3)) – The three corner positions of each triangle. Only
x0.shape[0](the triangle count) is used; the values themselves do not matter.
- Returns:
H – Per-triangle Hessian of each normal component over the nine DOFs.
- Return type:
np.ndarray (m, 3, 9, 9)