cazan_common/geometry/
triangle.rs1use crate::geometry::Point;
2use serde::{Deserialize, Serialize};
3#[cfg(feature = "wasm")]
4use wasm_bindgen::prelude::wasm_bindgen;
5
6#[cfg_attr(feature = "wasm", wasm_bindgen)]
7#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
8pub struct Triangle(pub Point, pub Point, pub Point);
9
10impl IntoIterator for Triangle {
11 type Item = Point;
12 type IntoIter = std::vec::IntoIter<Self::Item>;
13
14 fn into_iter(self) -> Self::IntoIter {
15 vec![self.0, self.1, self.2].into_iter()
16 }
17}
18
19impl PartialEq for Triangle {
20 fn eq(&self, other: &Self) -> bool {
21 let mut self_points = vec![self.0, self.1, self.2];
22 let mut other_points = vec![other.0, other.1, other.2];
23 self_points.sort();
24 other_points.sort();
25 self_points == other_points
26 }
27}