geomutil_util 0.1.2

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

#[derive(Clone)]
pub struct Shape2D {
    pub triangles: Vec<Triangle2>,
}

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

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