Camera::fit_in frames a box's corners in part of the view

The distance and the target follow from the eight corners' exact
projections, for orthographic and perspective cameras and any direction of
view, so a long beam seen side on fills the width instead of a sphere
around it the height (#147). The free part is given as fractions of the
view, so overlays can be left out (#76); a margin is kept on each side.
Camera::fit is fit_in over the whole of a square view, and the headless
renderer fits to the picture's aspect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
jyvikoandClaude Opus 5.5 authored and Irakli Kourtis committed 2026-10-14 22:29:44 -04:00
1 parent 696b64c30f
commit 29af2aef91
4 files changed
+158 -7

No files matched your search

+10
View File
@@ -121,6 +121,16 @@ impl Aabb3 {
pub fn diagonal(&self) -> f64 {
if self.is_empty() { 0.0 } else { self.max.dist(self.min) }
}
/// The eight corners (bit 0 picks x, bit 1 y, bit 2 z: min or max).
pub fn corners(&self) -> [Vec3; 8] {
std::array::from_fn(|k| {
Vec3::new(
if k & 1 == 0 { self.min.x } else { self.max.x },
if k & 2 == 0 { self.min.y } else { self.max.y },
if k & 4 == 0 { self.min.z } else { self.max.z },
)
})
}
}
#[cfg(test)]