qualia_core_db/tensor/
spacetime.rs1use serde::{Deserialize, Serialize};
4
5#[repr(C)]
7#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
8pub struct SpacetimeCoord {
9 pub x: f32,
10 pub y: f32,
11 pub z: f32,
12 pub t: f32,
13}
14
15impl Default for SpacetimeCoord {
16 fn default() -> Self {
17 Self {
18 x: 0.0,
19 y: 0.0,
20 z: 0.0,
21 t: 0.0,
22 }
23 }
24}
25
26impl SpacetimeCoord {
27 pub fn new(x: f32, y: f32, z: f32, t: f32) -> Self {
28 Self { x, y, z, t }
29 }
30
31 pub fn spatial_distance(&self, other: &Self) -> f32 {
32 let dx = self.x - other.x;
33 let dy = self.y - other.y;
34 let dz = self.z - other.z;
35 (dx * dx + dy * dy + dz * dz).sqrt()
36 }
37}