ncube 2.1.0

Generalized Hypercube Visualizer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use bevy::prelude::*;

#[derive(Debug)]
pub struct Edge();

impl Edge {
    /// Gets the transform for a unit cube so that it behaves like a 3
    /// dimensional segment from point `from` to point `to`.
    pub fn transform(thickness: f32, from: Vec3, to: Vec3) -> Transform {
        let diff = to - from;
        Transform {
            translation: (from + to) / 2.0,
            scale: Vec3::new(thickness, thickness, diff.length() + thickness),
            rotation: Quat::from_rotation_arc(Vec3::Z, diff.normalize()),
        }
    }
}