32 lines
557 B
Rust
32 lines
557 B
Rust
// SPDX-FileCopyrightText: 2026 Milovann Yanatchkov
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
use crate::math::Vec3;
|
|
|
|
/// A 3D point.
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub struct Point {
|
|
pub x: f64,
|
|
pub y: f64,
|
|
pub z: f64,
|
|
}
|
|
|
|
impl Point {
|
|
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 Point {
|
|
fn from(v: Vec3) -> Self {
|
|
Self {
|
|
x: v.x,
|
|
y: v.y,
|
|
z: v.z,
|
|
}
|
|
}
|
|
}
|