Skip to content

Commit 0582a1a

Browse files
committed
fix: normalize quad basis before computing verts
1 parent 34141e8 commit 0582a1a

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

pyraydeon/examples/py_rhombohedron.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ def __init__(self, origin, basis, dims):
2020
self.basis = basis
2121
self.dims = dims
2222

23+
self.faces = [
24+
[0, 1, 3, 2],
25+
[4, 5, 7, 6],
26+
[0, 1, 5, 4],
27+
[2, 3, 7, 6],
28+
[0, 2, 6, 4],
29+
[1, 3, 7, 5],
30+
]
31+
2332
combinations = np.array(np.meshgrid([0, 1], [0, 1], [0, 1])).T.reshape(-1, 3)
2433
scaled_combinations = combinations * dims
2534

@@ -37,14 +46,6 @@ def __init__(self, origin, basis, dims):
3746
move_vectors = unit_move_dirs * 0.0015
3847
self.path_vertices = self.vertices + move_vectors
3948

40-
self.faces = [
41-
[0, 1, 3, 2], # Bottom face
42-
[4, 5, 7, 6], # Top face
43-
[0, 1, 5, 4], # Front face
44-
[2, 3, 7, 6], # Back face
45-
[0, 2, 6, 4], # Left face
46-
[1, 3, 7, 5], # Right face
47-
]
4849
self.quads = self.compute_quads()
4950

5051
def __repr__(self):
@@ -87,31 +88,31 @@ def paths(self, cam):
8788
scene = Scene(
8889
[
8990
Rhombohedron(
90-
origin=np.array([0.0, 0.0, 0.0]),
91+
origin=np.array([0.0, 0.0, 0.2]),
9192
basis=np.array(
9293
[
93-
[0.9, 0.5, 0.0],
94+
[0.45, 0.2, -0.3],
9495
[-0.3, 1.0, 0.0],
95-
[-0.5, 0.25, -0.7],
96+
[-0.5, 0.0, -0.2],
9697
]
9798
),
98-
dims=np.array([1.0, 1.0, 1.0]),
99+
dims=np.array([2.0, 0.5, 1.0]),
99100
),
100101
Rhombohedron(
101-
origin=np.array([2.0, 0.0, -2.0]),
102+
origin=np.array([1.0, 0.0, -2.0]),
102103
basis=np.array(
103104
[
104105
[-0.9, 0.5, 0.0],
105106
[0.3, 1.0, 0.5],
106107
[1.5, 0.25, -0.7],
107108
]
108109
),
109-
dims=np.array([1.0, 1.0, 1.0]),
110+
dims=np.array([1.0, 1.0, 0.8]),
110111
),
111112
]
112113
)
113114

114-
eye = np.array([0, 0.4, 5])
115+
eye = np.array([0, -0.5, 5])
115116
focus = np.array([0, 0.4, 0])
116117
up = np.array([0, 1, 0])
117118

Lines changed: 1 addition & 1 deletion
Loading

raydeon/src/shapes/quad.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ impl Quad {
2020
}
2121

2222
pub fn tagged(origin: WPoint3, mut basis: [WVec3; 2], dims: [f64; 2], tag: usize) -> Quad {
23+
basis[0] = basis[0].normalize();
24+
basis[1] = basis[1].normalize();
2325
let verts = [
2426
origin,
2527
origin + basis[0] * dims[0],
2628
origin + basis[0] * dims[0] + basis[1] * dims[1],
2729
origin + basis[1] * dims[1],
2830
];
29-
basis[0] = basis[0].normalize();
30-
basis[1] = basis[1].normalize();
3131
Quad {
3232
origin,
3333
basis,
@@ -42,7 +42,7 @@ impl Shape<WorldSpace> for Quad {
4242
fn collision_geometry(&self) -> Option<Vec<std::sync::Arc<dyn CollisionGeometry<WorldSpace>>>> {
4343
Some(vec![
4444
Arc::new(Triangle::new(self.verts[0], self.verts[1], self.verts[3])),
45-
Arc::new(Triangle::new(self.verts[2], self.verts[3], self.verts[1])),
45+
Arc::new(Triangle::new(self.verts[1], self.verts[2], self.verts[3])),
4646
])
4747
}
4848

0 commit comments

Comments
 (0)