~starkingdoms/starkingdoms

ref: 0787932116e83f397529943035218f288ee1b695 starkingdoms/server/src/mathutil.rs -rw-r--r-- 299 bytes
07879321 — core api stuffs 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
use bevy::math::{vec2, Vec2, Vec3};

pub fn rot2d(uncast: Vec2, angle: f32) -> Vec2 {
    vec2(
        uncast.x * angle.cos() - uncast.y * angle.sin(),
        uncast.x * angle.sin() + uncast.y * angle.cos(),
    )
}

pub fn v3_to_v2(downgrade: Vec3) -> Vec2 {
    vec2(downgrade.x, downgrade.y)
}