fn max_centered_eq_triangle(dims: (i32, i32)) -> Triangle {
    let (x, y) = (dims.0 as f32, dims.1 as f32);
    let dims_center = (x / 2.0, y / 2.0);

    let sqrt3over2 = f32::sqrt(3.0) / 2.0;

    // Here, I'm trying to find if the height or width is the constraining dimension.
    // If it's the height, work backwards to find a side length,
    // If it's the width, use that as the side length
    let side_length = if x * sqrt3over2 > y {
        y / sqrt3over2
    } else {
        x
    };

    let top_center = Point {
        x: dims_center.0 as i32,
        y: (dims_center.1 - side_length * sqrt3over2 / 2.0) as i32,
    };

    let bottom_left = Point {
        x: (dims_center.0 - side_length / 2.0) as i32,
        y: (dims_center.1 + side_length * sqrt3over2 / 2.0) as i32,
    };

    let bottom_right = Point {
        x: (dims_center.0 + side_length / 2.0) as i32,
        y: (dims_center.1 + side_length * sqrt3over2 / 2.0) as i32,
    };

    Triangle {
        points: [top_center, bottom_left, bottom_right],
    }
}
/// Given the dimensions of an image to draw on, return the largest equilateral triangle
/// that fits on screen and is centered at the center of the screen
Given the dimensions of an image to draw on, return the largest equilateral triangle
that fits on screen and is centered at the center of the screen
Given the dimensions of an image to draw on return the largest equilateral triangle that fits on screen and is centered at the center of the screen
fn max_centered_eq_triangle(dims: (i32, i32)) -> Triangle {
    let (x, y) = (dims.0 as f32, dims.1 as f32);
    let dims_center = (x / 2.0, y / 2.0);
    let sqrt3over2 = f32::sqrt(3.0) / 2.0;
    // Here, I'm trying to find if the height or width is the constraining dimension.
    // If it's the height, work backwards to find a side length,
    // If it's the width, use that as the side length
    let side_length = if x * sqrt3over2 > y {
        y / sqrt3over2
    } else {
        x
    };
    let top_center = Point {
        x: dims_center.0 as i32,
        y: (dims_center.1 - side_length * sqrt3over2 / 2.0) as i32,
    };
    let bottom_left = Point {
        x: (dims_center.0 - side_length / 2.0) as i32,
        y: (dims_center.1 + side_length * sqrt3over2 / 2.0) as i32,
    };
    let bottom_right = Point {
        x: (dims_center.0 + side_length / 2.0) as i32,
        y: (dims_center.1 + side_length * sqrt3over2 / 2.0) as i32,
    };
    Triangle {
        points: [top_center, bottom_left, bottom_right],
    }
}
fn max_centered_eq_triangle ( dims : ( i32 , i32 ) ) -> Triangle { let ( x , y ) = ( dims . 0 as f32 , dims . 1 as f32 ) ; let dims_center = ( x / 2.0 , y / 2.0 ) ; let sqrt3over2 = f32 :: sqrt ( 3.0 ) / 2.0 ; // Here, I'm trying to find if the height or width is the constraining dimension. // If it's the height, work backwards to find a side length, // If it's the width, use that as the side length let side_length = if x * sqrt3over2 > y { y / sqrt3over2 } else { x } ; let top_center = Point { x : dims_center . 0 as i32 , y : ( dims_center . 1 - side_length * sqrt3over2 / 2.0 ) as i32 , } ; let bottom_left = Point { x : ( dims_center . 0 - side_length / 2.0 ) as i32 , y : ( dims_center . 1 + side_length * sqrt3over2 / 2.0 ) as i32 , } ; let bottom_right = Point { x : ( dims_center . 0 + side_length / 2.0 ) as i32 , y : ( dims_center . 1 + side_length * sqrt3over2 / 2.0 ) as i32 , } ; Triangle { points : [ top_center , bottom_left , bottom_right ] , } }
Given the dimensions of an image to draw on, return the largest equilateral triangle
that fits on screen and is centered at the center of the screen
Given the dimensions of an image to draw on return the largest equilateral triangle that fits on screen and is centered at the center of the screen
dims
(i32, i32)
dims
(i32, i32)