Computes the aspect ratio of the given triangle The aspect ratio is computed as the inverse of the "stretch ratio" `S` given by ```txt S = sqrt(12) * (r_in / l_max) ``` where `r_in` is the radius of the in-circle and `l_max` is the longest edge of the triangle. See e.g.: .
(
a: &Vector3<RIn>,
b: &Vector3<RIn>,
c: &Vector3<RIn>,
)
| 96 | /// where `r_in` is the radius of the in-circle and `l_max` is the longest edge of the triangle. |
| 97 | /// See e.g.: <https://www.engmorph.com/2d-element-aspect-ratio-diff-simula>. |
| 98 | pub fn tri_aspect_ratio<RIn: Real, RComp: Real>( |
| 99 | a: &Vector3<RIn>, |
| 100 | b: &Vector3<RIn>, |
| 101 | c: &Vector3<RIn>, |
| 102 | ) -> RComp { |
| 103 | let two = RComp::from_i32(2).unwrap(); |
| 104 | let sqrt_twelve = RComp::from_i32(12).unwrap().sqrt(); |
| 105 | |
| 106 | let a = a.convert::<RComp>(); |
| 107 | let b = b.convert::<RComp>(); |
| 108 | let c = c.convert::<RComp>(); |
| 109 | |
| 110 | let l0 = (a - b).norm(); |
| 111 | let l1 = (b - c).norm(); |
| 112 | let l2 = (c - a).norm(); |
| 113 | let s = (l0 + l1 + l2) / two; |
| 114 | |
| 115 | let area: RComp = tri_area(&a, &b, &c); |
| 116 | let r_in = area / s; |
| 117 | let l_max = l0.max(l1.max(l2)); |
| 118 | |
| 119 | l_max / (sqrt_twelve * r_in) |
| 120 | } |
| 121 | |
| 122 | /// Utility functions for triangles meshes |
| 123 | pub trait TriMesh3dExt<R: Real> { |
no test coverage detected