Created Small Project Directory

This commit is contained in:
2025-04-14 15:40:09 -05:00
commit da003eadb5
6 changed files with 2046 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

1949
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

6
Cargo.toml Normal file
View File

@@ -0,0 +1,6 @@
[workspace]
resolver = "3"
members = [
"quasi_lattices_3d",
]

View File

@@ -0,0 +1,7 @@
[package]
name = "lattice_3d"
version = "0.1.0"
edition = "2024"
[dependencies]
kiss3d = "0.35"

View 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
View 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;
}