Test for the bugfix
This commit is contained in:
parent
15a28df2ed
commit
c49a3ea241
|
|
@ -296,4 +296,58 @@ mod coords {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::{Location, Tube, MapperOuter};
|
||||||
|
use glam::{Mat2, vec2};
|
||||||
|
use itertools_num::linspace;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_mapper_outer() {
|
||||||
|
let mapper = Tube {
|
||||||
|
inner_radius: 30.0,
|
||||||
|
outer_radius: 50.0,
|
||||||
|
internal_halflength: 100.0,
|
||||||
|
external_halflength: 300.0,
|
||||||
|
};
|
||||||
|
// straight
|
||||||
|
for x in linspace(-60., 60., 20) {
|
||||||
|
for y in linspace(-320., 320., 20) {
|
||||||
|
assert_eq!(mapper.global_to_outer(Location { pos: vec2(x, y), rot: Mat2::IDENTITY }).pos.x, x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// symmetrical
|
||||||
|
for x in linspace(0., 60., 20) {
|
||||||
|
for y in linspace(0., 320., 20) {
|
||||||
|
let pp = mapper.global_to_outer(Location { pos: vec2(x, y), rot: Mat2::IDENTITY }).pos;
|
||||||
|
let np = mapper.global_to_outer(Location { pos: vec2(-x, y), rot: Mat2::IDENTITY }).pos;
|
||||||
|
let pn = mapper.global_to_outer(Location { pos: vec2(x, -y), rot: Mat2::IDENTITY }).pos;
|
||||||
|
let nn = mapper.global_to_outer(Location { pos: vec2(-x, -y), rot: Mat2::IDENTITY }).pos;
|
||||||
|
assert_eq!(np, vec2(-pp.x, pp.y));
|
||||||
|
assert_eq!(pn, vec2(pp.x, -pp.y));
|
||||||
|
assert_eq!(nn, vec2(-pp.x, -pp.y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// clean boundary
|
||||||
|
for x in linspace(50., 60., 20) {
|
||||||
|
for y in linspace(0., 320., 20) {
|
||||||
|
assert_eq!(mapper.global_to_outer(Location { pos: vec2(x, y), rot: Mat2::IDENTITY }).pos.y, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for x in linspace(0., 60., 20) {
|
||||||
|
for y in linspace(300., 320., 20) {
|
||||||
|
assert_eq!(mapper.global_to_outer(Location { pos: vec2(x, y), rot: Mat2::IDENTITY }).pos.y, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// accelerating
|
||||||
|
for x in linspace(-29., 29., 20) {
|
||||||
|
for y in linspace(1., 299., 20) {
|
||||||
|
let v = mapper.global_to_outer(Location { pos: vec2(x, y), rot: Mat2::IDENTITY }).pos.y;
|
||||||
|
assert!(v > 200.0);
|
||||||
|
assert!(v > y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user