fn area(triangle: &Triangle) -> i32 {
    let v = triangle.points;
    let (a, b, c) = (v[0], v[1], v[2]);

    let ar = (a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y)) / 2;

    // You have to take the absolute value of the triangle because handedness comes into
    // play with the determinant but the magnitude always equals the area
    return ar.abs();
}
/// A helper function to calculate the area of a triangle based solely on the coordinates
/// of its vertices. This formula comes from taking half the determinant of a matrix set
/// up like:
/// ```
///     1   |  a_x  a_y  1  |
/// A = _ * |  b_x  b_y  1  |
///     2   |  c_x  c_y  1  |
/// ```
///
/// # Arguments
///
/// * `triangle: &Triangle` - A triangle to calculate the area of
A helper function to calculate the area of a triangle based solely on the coordinates
of its vertices.
A helper function to calculate the area of a triangle based solely on the coordinates of its vertices .
fn area(triangle: &Triangle) -> i32 {
    let v = triangle.points;
    let (a, b, c) = (v[0], v[1], v[2]);
    let ar = (a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y)) / 2;
    // You have to take the absolute value of the triangle because handedness comes into
    // play with the determinant but the magnitude always equals the area
    return ar.abs();
}
fn area ( triangle : & Triangle ) -> i32 { let v = triangle . points ; let ( a , b , c ) = ( v [ 0 ] , v [ 1 ] , v [ 2 ] ) ; let ar = ( a . x * ( b . y - c . y ) + b . x * ( c . y - a . y ) + c . x * ( a . y - b . y ) ) / 2 ; // You have to take the absolute value of the triangle because handedness comes into // play with the determinant but the magnitude always equals the area return ar . abs ( ) ; }
A helper function to calculate the area of a triangle based solely on the coordinates
of its vertices.
A helper function to calculate the area of a triangle based solely on the coordinates of its vertices .
triangle
&Triangle
triangle
&Triangle