qualia_core_db/domains/geospatial/
scale_continuum.rs1use crate::domains::geospatial::reference_frame::ReferenceFrame;
7
8pub fn requires_micro_transition(camera_scale: f64, active_frame: &ReferenceFrame) -> bool {
14 let scale_ratio = camera_scale / active_frame.scale;
15 scale_ratio > 1000.0
16}
17
18pub fn is_contained_in_parent(
25 local_pt: [f64; 3],
26 frame: &ReferenceFrame,
27 parent_bounds_min: [f64; 3],
28 parent_bounds_max: [f64; 3],
29) -> bool {
30 let global_pt = frame.transform_to_parent(local_pt);
31
32 global_pt[0] >= parent_bounds_min[0]
33 && global_pt[0] <= parent_bounds_max[0]
34 && global_pt[1] >= parent_bounds_min[1]
35 && global_pt[1] <= parent_bounds_max[1]
36 && global_pt[2] >= parent_bounds_min[2]
37 && global_pt[2] <= parent_bounds_max[2]
38}
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43 use crate::domains::geospatial::reference_frame::ReferenceFrame;
44
45 #[test]
46 fn test_requires_micro_transition() {
47 let frame = ReferenceFrame::new(1, None); assert!(!requires_micro_transition(100.0, &frame));
50 assert!(requires_micro_transition(1001.0, &frame));
51 }
52
53 #[test]
54 fn test_is_contained_in_parent() {
55 let mut frame = ReferenceFrame::new(2, Some(1));
56 frame.translation = [10.0, 10.0, 10.0];
57 frame.scale = 0.1;
58
59 let local_pt = [5.0, 0.0, 0.0];
60 let min_bounds = [0.0, 0.0, 0.0];
63 let max_bounds = [20.0, 20.0, 20.0];
64
65 assert!(is_contained_in_parent(
66 local_pt, &frame, min_bounds, max_bounds
67 ));
68
69 let out_bounds = [0.0, 0.0, 1.0];
71 assert!(!is_contained_in_parent(
72 local_pt, &frame, min_bounds, out_bounds
73 ));
74 }
75}