41 lines
873 B
Rust
41 lines
873 B
Rust
// SPDX-FileCopyrightText: 2026 Milovann Yanatchkov
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
use crate::math::Vec3;
|
|
|
|
/// A 3D direction vector — a graph entity wrapping the math primitive.
|
|
///
|
|
/// `math::Vec3` is the numeric backbone; this entity surface is what the DSL,
|
|
/// graph, and WASM/PyO3 adapters carry as parameter/result values.
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub struct Vector {
|
|
pub x: f64,
|
|
pub y: f64,
|
|
pub z: f64,
|
|
}
|
|
|
|
impl Vector {
|
|
pub fn new(x: f64, y: f64, z: f64) -> Self {
|
|
Self { x, y, z }
|
|
}
|
|
|
|
pub fn to_vec3(self) -> Vec3 {
|
|
Vec3::new(self.x, self.y, self.z)
|
|
}
|
|
}
|
|
|
|
impl From<Vec3> for Vector {
|
|
fn from(v: Vec3) -> Self {
|
|
Self {
|
|
x: v.x,
|
|
y: v.y,
|
|
z: v.z,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<Vector> for Vec3 {
|
|
fn from(v: Vector) -> Self {
|
|
Vec3::new(v.x, v.y, v.z)
|
|
}
|
|
}
|