Created Small Project Directory
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/target
|
||||
1949
Cargo.lock
generated
Normal file
1949
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
6
Cargo.toml
Normal file
6
Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[workspace]
|
||||
resolver = "3"
|
||||
members = [
|
||||
"quasi_lattices_3d",
|
||||
]
|
||||
|
||||
7
quasi_lattices_3d/Cargo.toml
Normal file
7
quasi_lattices_3d/Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "lattice_3d"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
kiss3d = "0.35"
|
||||
67
quasi_lattices_3d/src/main.rs
Normal file
67
quasi_lattices_3d/src/main.rs
Normal file
@@ -0,0 +1,67 @@
|
||||
use kiss3d::nalgebra::{
|
||||
DMatrix,
|
||||
//U2,
|
||||
//Dynamic,
|
||||
//Point3,
|
||||
Translation3,
|
||||
//Vector2,
|
||||
//Vector3,
|
||||
//UnitQuaternion
|
||||
};
|
||||
use kiss3d::window::Window;
|
||||
use kiss3d::light::Light;
|
||||
|
||||
const DIMENSION: usize = 3;
|
||||
const SIZE: usize = 2;
|
||||
|
||||
fn generate_matrix() -> DMatrix<f32> {
|
||||
let theta = 2.0 * std::f32::consts::PI / DIMENSION as f32;
|
||||
|
||||
let mut entries = Vec::new();
|
||||
for i in 0..DIMENSION {
|
||||
entries.push((i as f32 * theta).cos());
|
||||
entries.push((i as f32 * theta).sin());
|
||||
entries.push(1.0);
|
||||
}
|
||||
let matrix = DMatrix::from_vec(3, DIMENSION, entries);
|
||||
|
||||
matrix
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut window = Window::new("3D Lattice");
|
||||
|
||||
window.set_light(Light::StickToCamera);
|
||||
|
||||
let projection_matrix = generate_matrix();
|
||||
|
||||
let mut points: Vec<Vec<f32>> = Vec::new();
|
||||
let origin = vec![0.0;DIMENSION];
|
||||
points.push(origin);
|
||||
|
||||
for i in 0..DIMENSION {
|
||||
let mut new_points = points.clone();
|
||||
for point in &points {
|
||||
for j in 0..SIZE {
|
||||
let mut new_point = point.clone();
|
||||
new_point[i] = j as f32;
|
||||
new_points.push(new_point);
|
||||
}
|
||||
}
|
||||
points = new_points;
|
||||
}
|
||||
|
||||
for point in &points {
|
||||
let vector = DMatrix::from_vec(DIMENSION, 1, point.to_vec());
|
||||
let result = &projection_matrix*vector;
|
||||
|
||||
let mut sphere = window.add_cube(0.05,0.05,0.05);
|
||||
|
||||
sphere.set_color(1.0, 1.0, 1.0);
|
||||
|
||||
sphere.append_translation(&Translation3::new(result[(0,0)], result[(1,0)], result[(2,0)]));
|
||||
}
|
||||
|
||||
while window.render() {
|
||||
}
|
||||
}
|
||||
16
shell.nix
Normal file
16
shell.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{ pkgs ? import <nixpkgs> { } }:
|
||||
|
||||
with pkgs;
|
||||
|
||||
mkShell rec {
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
];
|
||||
buildInputs = [
|
||||
udev alsa-lib vulkan-loader
|
||||
xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr # To use the x11 feature
|
||||
libxkbcommon wayland # To use the wayland feature
|
||||
libGL
|
||||
];
|
||||
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
|
||||
}
|
||||
Reference in New Issue
Block a user