eryon_surface/points/types/kinds.rs
1/*
2 Appellation: kinds <module>
3 Contrib: @FL03
4*/
5
6/// Enumerates the different kinds of points considered by the system
7///
8/// - Barycentric (critical points): points defining a barycentric coordinate for the facet
9#[derive(
10 Clone,
11 Copy,
12 Debug,
13 Eq,
14 Hash,
15 Ord,
16 PartialEq,
17 PartialOrd,
18 strum::AsRefStr,
19 strum::Display,
20 strum::EnumCount,
21 strum::EnumIs,
22 strum::EnumIter,
23 strum::EnumString,
24 strum::VariantArray,
25 strum::VariantNames,
26)]
27#[cfg_attr(
28 feature = "serde",
29 derive(serde_derive::Deserialize, serde_derive::Serialize),
30 serde(rename_all = "snake_case")
31)]
32#[strum(serialize_all = "snake_case")]
33pub enum PointKind {
34 /// the topology of a 2-simplex naturally defines a maximum of three barycentric coordinates
35 /// which are used to define the three critical points of the network
36 Barycentric,
37 /// the centroid is the geometric center of the triad, defined as the average of the three vertices
38 Centroid,
39 /// the root (tonic) of the facet
40 Root,
41 /// the middle vertex (note) of the facet
42 Third,
43 /// the final vertex (note) of the facet
44 Fifth,
45}
46
47impl PointKind {
48 /// Get default barycentric coordinates for this kind
49 pub fn default_coordinates<T>(&self) -> [T; 3]
50 where
51 T: num_traits::Float + num_traits::FromPrimitive,
52 {
53 [T::from_f32(1.0 / 3.0).unwrap(); 3]
54 }
55}