use nalgebra_glm as glm; use shine_math::geometry2::Real; /// Trait to convert sample points for test cases pub trait FromSample { fn from_sample(x: f32, y: f32) -> Self; } impl FromSample for glm::TVec2 { fn from_sample(x: f32, y: f32) -> glm::TVec2 { glm::vec2(x as f32, y as f32) } } impl FromSample for glm::TVec2 { fn from_sample(x: f32, y: f32) -> glm::TVec2 { glm::vec2(x as f64, y as f64) } } impl FromSample for glm::TVec2 { fn from_sample(x: f32, y: f32) -> glm::TVec2 { glm::vec2((x * 2048.) as i32, (y * 2048.) as i32) } } impl FromSample for glm::TVec2 { fn from_sample(x: f32, y: f32) -> glm::TVec2 { glm::vec2((x * 65536.) as i64, (y * 65536.) as i64) } } pub fn sample_vec(x: f32, y: f32) -> glm::TVec2 where R: 'static + Real, glm::TVec2: FromSample, { as FromSample>::from_sample(x, y) }