From aae9ba5e8031797d001084864875c4ef717ba665 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 12 Sep 2024 12:16:19 -0700 Subject: [PATCH] define more functions --- src/gameplay_style.rs | 2 +- src/integer.rs | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/gameplay_style.rs b/src/gameplay_style.rs index 5853209..3ee08a5 100644 --- a/src/gameplay_style.rs +++ b/src/gameplay_style.rs @@ -1,6 +1,6 @@ const VALVE_SCALE:Planar64=Planar64::raw(1<<28);// 1/16 -use crate::integer::{int,int3,Time,Ratio64,Planar64,Planar64Vec3}; +use crate::integer::{int,vec3::int as int3,Time,Ratio64,Planar64,Planar64Vec3}; use crate::controls_bitflag::Controls; #[derive(Clone,Debug)] diff --git a/src/integer.rs b/src/integer.rs index 489629a..3463ce6 100644 --- a/src/integer.rs +++ b/src/integer.rs @@ -1,5 +1,5 @@ -use fixed_wide::fixed::Fixed; -use ratio_ops::ratio::Ratio; +pub use fixed_wide::fixed::Fixed; +pub use ratio_ops::ratio::Ratio; //integer units #[derive(Clone,Copy,Hash,Eq,PartialEq,PartialOrd,Debug)] @@ -451,13 +451,32 @@ pub mod vec3{ pub const NEG_X:Planar64Vec3=Planar64Vec3::new([Planar64::NEG_ONE,Planar64::ZERO,Planar64::ZERO]); pub const NEG_Y:Planar64Vec3=Planar64Vec3::new([Planar64::ZERO,Planar64::NEG_ONE,Planar64::ZERO]); pub const NEG_Z:Planar64Vec3=Planar64Vec3::new([Planar64::ZERO,Planar64::ZERO,Planar64::NEG_ONE]); + pub fn int(x:i32,y:i32,z:i32)->Planar64Vec3{ + Planar64Vec3::new([Planar64::from(x),Planar64::from(y),Planar64::from(z)]) + } + pub fn raw_xyz(x:i64,y:i64,z:i64)->Planar64Vec3{ + Planar64Vec3::new([Planar64::raw(x),Planar64::raw(y),Planar64::raw(z)]) + } } pub fn int(value:i32)->Planar64{ Planar64::from(value) } -pub fn int3(x:i32,y:i32,z:i32)->Planar64Vec3{ - Planar64Vec3::new([Planar64::from(x),Planar64::from(y),Planar64::from(z)]) +pub mod mat3{ + use super::*; + pub fn from_diagonal(diag:Planar64Vec3)->Planar64Mat3{ + Planar64Mat3::new([ + [diag.x,Planar64::ZERO,Planar64::ZERO], + [Planar64::ZERO,diag.y,Planar64::ZERO], + [Planar64::ZERO,Planar64::ZERO,diag.z], + ]) + } + pub fn from_rotation_yx(x:Angle32,y:Angle32)->Planar64Mat3{ + todo!() + } + pub fn from_rotation_y(y:Angle32)->Planar64Mat3{ + todo!() + } } #[test]