geomutil_util 0.1.1

A Rust library providing basic geometric types.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::Triangle2D;

pub struct Shape2D {
    pub triangles: Vec<Triangle2D>,
}

impl Shape2D {
    pub fn new(triangles: Vec<Triangle2D>) -> Self {
        Self { triangles }
    }

    pub fn area(&self) -> f32 {
        self.triangles.iter().map(|t| t.area()).sum()
    }
}