summaryrefslogtreecommitdiff
path: root/2026/games/asrael_io/source/src/math.rs
blob: 371f165270dcfdf8883c0ec8b1f53e43ab943005 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
use glam::Vec2;

pub fn aabb(a_pos: Vec2, a_size: Vec2, b_pos: Vec2, b_size: Vec2) -> bool {
    a_pos.x < b_pos.x + b_size.x
        && b_pos.x < a_pos.x + a_size.x
        && a_pos.y < b_pos.y + b_size.y
        && b_pos.y < a_pos.y + a_size.y
}

pub fn bezier(p: [Vec2; 4], t: f32) -> Vec2 {
    let u = 1.0 - t;
    u * u * u * p[0] + 3.0 * u * u * t * p[1] + 3.0 * u * t * t * p[2] + t * t * t * p[3]
}