mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
from rotation accept generic fixnum
This commit is contained in:
parent
99f01caea4
commit
d83f0ea710
|
@ -34,18 +34,21 @@ impl AffineMatrix {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn from_rotation(angle: Num<i32, 16>) -> Self {
|
pub fn from_rotation<const N: usize>(angle: Num<i32, N>) -> Self {
|
||||||
let cos = angle.cos().change_base();
|
fn from_rotation(angle: Num<i32, 28>) -> AffineMatrix {
|
||||||
let sin = angle.sin().change_base();
|
let cos = angle.cos().change_base();
|
||||||
|
let sin = angle.sin().change_base();
|
||||||
|
|
||||||
AffineMatrix {
|
AffineMatrix {
|
||||||
a: cos,
|
a: cos,
|
||||||
b: sin,
|
b: sin,
|
||||||
c: -sin,
|
c: -sin,
|
||||||
d: cos,
|
d: cos,
|
||||||
x: 0.into(),
|
x: 0.into(),
|
||||||
y: 0.into(),
|
y: 0.into(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
from_rotation(angle.rem_euclid(1.into()).change_base())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Identity for rotation / scale / skew
|
// Identity for rotation / scale / skew
|
||||||
|
@ -167,7 +170,7 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(c.position(), position);
|
assert_eq!(c.position(), position);
|
||||||
|
|
||||||
let d = AffineMatrix::from_rotation(num!(0.5));
|
let d = AffineMatrix::from_rotation::<2>(num!(0.5));
|
||||||
|
|
||||||
let e = a * d;
|
let e = a * d;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue