-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c86f01d
commit 07d8878
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
pub fn from_list_of_vertices( | ||
idx2vtx: &[usize], | ||
vtx2xyz: &[f32], | ||
eps: f32) -> (nalgebra::Vector3::<f32>, nalgebra::Vector3::<f32>) | ||
{ | ||
assert!(!idx2vtx.is_empty()); | ||
let mut min = nalgebra::Vector3::<f32>::zeros(); | ||
let mut max = nalgebra::Vector3::<f32>::zeros(); | ||
{ | ||
let i_vtx = idx2vtx[0]; | ||
{ | ||
let cgx = vtx2xyz[i_vtx * 3 + 0]; | ||
min.x = cgx - eps; | ||
max.x = cgx + eps; | ||
} | ||
{ | ||
let cgy = vtx2xyz[i_vtx * 3 + 1]; | ||
min.y = cgy - eps; | ||
max.y = cgy + eps; | ||
} | ||
{ | ||
let cgz = vtx2xyz[i_vtx * 3 + 2]; | ||
min.z = cgz - eps; | ||
max.z = cgz + eps; | ||
} | ||
} | ||
for &i_vtx in idx2vtx.iter().skip(1) { | ||
{ | ||
let cgx = vtx2xyz[i_vtx * 3 + 0]; | ||
min.x = if cgx - eps < min.x { cgx - eps } else { min.x }; | ||
max.x = if cgx + eps > max.x { cgx + eps } else { max.x }; | ||
} | ||
{ | ||
let cgy = vtx2xyz[i_vtx * 3 + 1]; | ||
min.y = if cgy - eps < min.y { cgy - eps } else { min.y }; | ||
max.y = if cgy + eps > max.y { cgy + eps } else { max.y }; | ||
} | ||
{ | ||
let cgz = vtx2xyz[i_vtx * 3 + 2]; | ||
min.z = if cgz - eps < min.z { cgz - eps } else { min.z }; | ||
max.z = if cgz + eps > max.z { cgz + eps } else { max.z }; | ||
} | ||
} | ||
assert!(min.x <= max.x); | ||
assert!(min.y <= max.y); | ||
assert!(min.z <= max.z); | ||
(min, max) | ||
} | ||
|
||
pub fn from_two_aabbs_slice6( | ||
i0: &[f32], | ||
i1: &[f32]) -> [f32; 6] | ||
{ | ||
assert_eq!(i0.len(), 6); | ||
assert_eq!(i1.len(), 6); | ||
let mut o = [0_f32; 6]; | ||
for i in 0..3 { | ||
o[i + 0] = if i0[i] < i1[i] { i0[i] } else { i1[i] }; | ||
o[i + 3] = if i0[i] > i1[i] { i0[i] } else { i1[i] }; | ||
} | ||
o | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
*/ | ||
pub mod vec3; | ||
pub mod mat3; | ||
pub mod aabb3; | ||
// | ||
pub mod line; | ||
pub mod line3; | ||
|