shape_core/elements/lines/line_3d/
mod.rs1use super::*;
2
3mod constructors;
4#[cfg_attr(feature = "serde", repr(C), derive(Serialize, Deserialize))]
6#[derive(Copy, Clone, PartialEq, Eq, Hash)]
7pub struct Line3D<T> {
8 pub s: Point3D<T>,
10 pub e: Point3D<T>,
12}
13
14#[cfg_attr(feature = "serde", repr(C), derive(Serialize, Deserialize))]
15#[derive(Copy, Clone, PartialEq, Eq, Hash)]
16pub struct Vector3D<T> {
17 pub dx: T,
18 pub dy: T,
19 pub dz: T,
20}
21
22impl<T> Line3D<T> {
23 pub fn new<P>(start: P, end: P) -> Self
25 where
26 Point3D<T>: From<P>,
27 {
28 Self { s: start.into(), e: end.into() }
29 }
30}
31
32impl<T: Real> Line3D<T> {
33 pub fn quantile_point(&self, p: usize, q: usize) -> Point3D<T> {
34 let _ = (p, q);
35 todo!()
36 }
37 pub fn middle_point(&self) -> Point3D<T> {
39 let mx = (self.s.x + self.e.x) / two();
40 let my = (self.s.y + self.e.y) / two();
41 let mz = (self.s.z + self.e.z) / two();
42 Point3D { x: mx, y: my, z: mz }
43 }
44}