Added a few methods to compute faces area
This commit is contained in:
parent
191ca7fdd6
commit
e508e01359
13
src/model.rs
13
src/model.rs
|
@ -211,6 +211,19 @@ impl Model {
|
|||
parse(path)
|
||||
}
|
||||
|
||||
/// Computes the area of a 3D face of the model.
|
||||
pub fn face_area(&self, f: &Face) -> f64 {
|
||||
self.face_vertex_area(&f.a, &f.b, &f.c)
|
||||
}
|
||||
|
||||
/// Computes the 3D area of a face from 3 face vertices.
|
||||
pub fn face_vertex_area(&self, a: &FaceVertex, b: &FaceVertex, c: &FaceVertex) -> f64 {
|
||||
let v1 = self.vertices[a.vertex];
|
||||
let v2 = self.vertices[b.vertex];
|
||||
let v3 = self.vertices[c.vertex];
|
||||
Vector3::area(v1, v2, v3)
|
||||
}
|
||||
|
||||
/// Returns the name of the current material, i.e. the material corresponding to the current
|
||||
/// part.
|
||||
pub fn current_material_name(&self) -> Option<String> {
|
||||
|
|
Loading…
Reference in New Issue