glam-rs
glam-rs copied to clipboard
`within` method for `Vec2` and `Vec3`
A method to check if a point self is somewhere inside the area of a rectangle with point a being the top-left corner and point b being the bottom-right corner.
pub fn within(&self, a: &Vec2, b: &Vec2) -> bool
example:
let a = Vec2::ZERO;
let b = Vec2::ONE;
assert!(Vec2::(0.5, 0.5).within(&a, &b))
assert!(Vec2::ONE.within(&a, &b))
assert!(Vec2::(1.5, 0.25).within(&a, &b)) // Assertion fails because `1.5 > 1.0`
I'm a bit undecided on this one. It feels like something that might be better supported in some kind of 2D bounding box type, put for now that is out of scope for glam.