fn relative_size_on_screen(bounding_cube: &Cube, matrix: &Matrix4<f32>) -> f32 {
    // z is unused here.
    let min = bounding_cube.min();
    let max = bounding_cube.max();
    let mut rv = Aabb3::zero();
    for p in &[
        Point3::new(min.x, min.y, min.z),
        Point3::new(max.x, min.y, min.z),
        Point3::new(min.x, max.y, min.z),
        Point3::new(max.x, max.y, min.z),
        Point3::new(min.x, min.y, max.z),
        Point3::new(max.x, min.y, max.z),
        Point3::new(min.x, max.y, max.z),
        Point3::new(max.x, max.y, max.z),
    ] {
        rv = rv.grow(project(matrix, p));
    }
    (rv.max().x - rv.min().x) * (rv.max().y - rv.min().y)
}
// This method projects world points through the matrix and returns a value proportional to the
// size of the screen. We do not know the width and height of the frustum in pixels here, so the
// unit of the value is not really well defined.
// Ideally we'd need to know the aspect ration of width/height to make the returned value truly
// proportional to the size on the screen, but this parameter would need to be passed through to
// all API calls. I decided on relying on a 'good enough' metric instead which did not require the
// parameter.
This method projects world points through the matrix and returns a value proportional to the
size of the screen. We do not know the width and height of the frustum in pixels here, so the
unit of the value is not really well defined.
Ideally we'd need to know the aspect ration of width/height to make the returned value truly
proportional to the size on the screen, but this parameter would need to be passed through to
all API calls. I decided on relying on a 'good enough' metric instead which did not require the
parameter.
This method projects world points through the matrix and returns a value proportional to the size of the screen . We do not know the width and height of the frustum in pixels here so the unit of the value is not really well defined . Ideally we ' d need to know the aspect ration of width / height to make the returned value truly proportional to the size on the screen but this parameter would need to be passed through to all API calls . I decided on relying on a ' good enough ' metric instead which did not require the parameter .
fn relative_size_on_screen(bounding_cube: &Cube, matrix: &Matrix4<f32>) -> f32 {
    // z is unused here.
    let min = bounding_cube.min();
    let max = bounding_cube.max();
    let mut rv = Aabb3::zero();
    for p in &[
        Point3::new(min.x, min.y, min.z),
        Point3::new(max.x, min.y, min.z),
        Point3::new(min.x, max.y, min.z),
        Point3::new(max.x, max.y, min.z),
        Point3::new(min.x, min.y, max.z),
        Point3::new(max.x, min.y, max.z),
        Point3::new(min.x, max.y, max.z),
        Point3::new(max.x, max.y, max.z),
    ] {
        rv = rv.grow(project(matrix, p));
    }
    (rv.max().x - rv.min().x) * (rv.max().y - rv.min().y)
}
fn relative_size_on_screen ( bounding_cube : & Cube , matrix : & Matrix4 < f32 > ) -> f32 { // z is unused here. let min = bounding_cube . min ( ) ; let max = bounding_cube . max ( ) ; let mut rv = Aabb3 :: zero ( ) ; for p in & [ Point3 :: new ( min . x , min . y , min . z ) , Point3 :: new ( max . x , min . y , min . z ) , Point3 :: new ( min . x , max . y , min . z ) , Point3 :: new ( max . x , max . y , min . z ) , Point3 :: new ( min . x , min . y , max . z ) , Point3 :: new ( max . x , min . y , max . z ) , Point3 :: new ( min . x , max . y , max . z ) , Point3 :: new ( max . x , max . y , max . z ) , ] { rv = rv . grow ( project ( matrix , p ) ) ; } ( rv . max ( ) . x - rv . min ( ) . x ) * ( rv . max ( ) . y - rv . min ( ) . y ) }
This method projects world points through the matrix and returns a value proportional to the
size of the screen.
This method projects world points through the matrix and returns a value proportional to the size of the screen .
bounding_cube
&Cube
matrix
&Matrix4<f32>
bounding_cube
&Cube
matrix
&Matrix4<f32>