PISM, A Parallel Ice Sheet Model
stable v2.1.1 committed by Constantine Khrulev on 2024-12-04 13:36:58 -0900
|
◆ triangle_area()
Consider the right triangle A(0,0) - B(1,0) - C(0,1). Define a linear function z = a + (b - a) * x + (c - a) * y, where a, b, and c are its values at points A, B, and C, respectively. Our goal is to find the fraction of the area of ABC in where z > 0. We note that z(x,y) is continuous, so unless a, b, and c have the same sign the line z = 0 will intersect exactly two of the sides (possibly at a node of ABC). So, if the line (z = 0) does not intersect BC, for example, then it has to intersect AB and AC. This method can be applied to arbitrary triangles. It does not even matter if values at triangle nodes (a, b, c) are listed in the same order. (For any two triangles on a plane there exists an affine map that takes one to the other. Also, affine maps preserve ratios of areas of figures.) Compute the area of a triangle on a plane using the "shoelace formula." Definition at line 62 of file grounded_cell_fraction.cc. References pism::Point::x, and pism::Point::y. Referenced by grounded_area_fraction(). |