Skip to main content

qualia_core_db/domains/geospatial/
ar_anchor.rs

1/// Physical anchor tying a virtual coordinate to a physical spatial location
2/// Compliant with the Spatial Web Anchoring Spec (UWB/VPS anchoring).
3pub struct PhysicalAnchor {
4    pub virtual_position: (f64, f64, f64), // XYZ in scene coordinates
5    pub physical_id: String,               // UWB beacon ID or VPS feature hash
6    pub confidence: f64,                   // 0.0 to 1.0 confidence in tracking
7    pub is_active: bool,
8}
9
10impl PhysicalAnchor {
11    pub fn new(vx: f64, vy: f64, vz: f64, id: String) -> Self {
12        Self {
13            virtual_position: (vx, vy, vz),
14            physical_id: id,
15            confidence: 1.0,
16            is_active: true,
17        }
18    }
19}
20
21/// Represents the state of the AR device (camera tracking, passthrough mode)
22pub struct ArDeviceState {
23    pub camera_pose: (f64, f64, f64, f64, f64, f64), // (x,y,z, yaw,pitch,roll)
24    pub passthrough_enabled: bool,
25    pub tracking_confidence: f64, // 0.0 = lost, 1.0 = perfect
26    pub anchors: Vec<PhysicalAnchor>,
27}
28
29impl ArDeviceState {
30    pub fn new() -> Self {
31        Self {
32            camera_pose: (0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
33            passthrough_enabled: false,
34            tracking_confidence: 0.0,
35            anchors: Vec::new(),
36        }
37    }
38
39    pub fn update_pose(&mut self, pose: (f64, f64, f64, f64, f64, f64), confidence: f64) {
40        self.camera_pose = pose;
41        self.tracking_confidence = confidence;
42    }
43
44    pub fn add_anchor(&mut self, anchor: PhysicalAnchor) {
45        self.anchors.push(anchor);
46    }
47}