App: use general test assembly from inversive-display
This moves us toward dropping the separate display prototype.
This commit is contained in:
parent
28b1ecb8e9
commit
4f8f36053f
2 changed files with 67 additions and 12 deletions
27
app-proto/full-interface/src/engine.rs
Normal file
27
app-proto/full-interface/src/engine.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
use nalgebra::DVector;
|
||||
|
||||
// the sphere with the given center and radius, with inward-pointing normals
|
||||
pub fn sphere(center_x: f64, center_y: f64, center_z: f64, radius: f64) -> DVector<f64> {
|
||||
let center_norm_sq = center_x * center_x + center_y * center_y + center_z * center_z;
|
||||
DVector::from_column_slice(&[
|
||||
center_x / radius,
|
||||
center_y / radius,
|
||||
center_z / radius,
|
||||
0.5 / radius,
|
||||
0.5 * (center_norm_sq / radius - radius)
|
||||
])
|
||||
}
|
||||
|
||||
// the sphere of curvature `curv` whose closest point to the origin has position
|
||||
// `off * dir` and normal `dir`, where `dir` is a unit vector. setting the
|
||||
// curvature to zero gives a plane
|
||||
pub fn sphere_with_offset(dir_x: f64, dir_y: f64, dir_z: f64, off: f64, curv: f64) -> DVector<f64> {
|
||||
let norm_sp = 1.0 + off * curv;
|
||||
DVector::from_column_slice(&[
|
||||
norm_sp * dir_x,
|
||||
norm_sp * dir_y,
|
||||
norm_sp * dir_z,
|
||||
0.5 * curv,
|
||||
off * (1.0 + 0.5 * off * curv)
|
||||
])
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue