mirror of
https://github.com/ricoriedel/wipe.git
synced 2024-12-23 06:36:42 +00:00
Fix angle function
This commit is contained in:
parent
35b555a04b
commit
96390b09b9
@ -35,12 +35,12 @@ mod test {
|
|||||||
fn sample() {
|
fn sample() {
|
||||||
let anim = RotationAnimation::new(Vector::new(30.0, 10.0));
|
let anim = RotationAnimation::new(Vector::new(30.0, 10.0));
|
||||||
|
|
||||||
let sample_1 = anim.sample(0.2, Vector::new(5.0, 16.0));
|
let sample_1 = anim.sample(0.3, Vector::new(16.0, 3.0));
|
||||||
let sample_2 = anim.sample(0.7, Vector::new(22.0, 2.0));
|
let sample_2 = anim.sample(0.7, Vector::new(22.0, 2.0));
|
||||||
let sample_3 = anim.sample(0.5, Vector::new(4.0, 7.0));
|
let sample_3 = anim.sample(0.5, Vector::new(4.0, 7.0));
|
||||||
|
|
||||||
assert!(2.4 < sample_1 && sample_1 < 2.5);
|
assert!(0.6 < sample_1 && sample_1 < 0.7);
|
||||||
assert!(0.7 < sample_2 && sample_2 < 0.8);
|
assert!(-3.1 < sample_2 && sample_2 < -3.0);
|
||||||
assert!(-2.3 < sample_3 && sample_3 < -2.2);
|
assert!(4.7 < sample_3 && sample_3 < 4.8);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,7 +24,7 @@ impl Vector {
|
|||||||
|
|
||||||
/// Returns the angle.
|
/// Returns the angle.
|
||||||
pub fn angle(self) -> f32 {
|
pub fn angle(self) -> f32 {
|
||||||
self.x.atan2(self.y)
|
self.y.atan2(self.x)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the value of the smaller axis.
|
/// Returns the value of the smaller axis.
|
||||||
@ -86,6 +86,13 @@ mod test {
|
|||||||
assert!(6.7 < vec.length() && vec.length() < 6.8);
|
assert!(6.7 < vec.length() && vec.length() < 6.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn angle() {
|
||||||
|
let vec = Vector::new(3.0, 6.0);
|
||||||
|
|
||||||
|
assert!(1.1 < vec.angle() && vec.angle() < 1.2);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn smaller() {
|
fn smaller() {
|
||||||
assert_eq!(4.0, Vector::new(7.0, 4.0).smaller());
|
assert_eq!(4.0, Vector::new(7.0, 4.0).smaller());
|
||||||
|
Loading…
Reference in New Issue
Block a user