Added a few methods to compute faces area

This commit is contained in:
Thomas Forgione 2018-03-31 03:05:24 +02:00
parent 191ca7fdd6
commit e508e01359
No known key found for this signature in database
GPG Key ID: C75CD416BD1FFCE1
1 changed files with 13 additions and 0 deletions

View File

@ -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> {