File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 11use crate :: { Float , Pt } ;
22
3- pub fn area ( ring : & [ Pt ] ) -> Float {
3+ #[ allow( clippy:: unnecessary_cast) ]
4+ // Note that we need to disable the clippy warning about unnecessary casts
5+ // because of the "f32" optional feature (and because we want to ensure we always
6+ // use "f64" in this function, both in the default feature and in the "f32" feature).
7+ pub fn area ( ring : & [ Pt ] ) -> f64 {
48 let n = ring. len ( ) ;
5- let mut area = ring[ n - 1 ] . y * ring[ 0 ] . x - ring[ n - 1 ] . x * ring[ 0 ] . y ;
9+ let mut area =
10+ ring[ n - 1 ] . y as f64 * ring[ 0 ] . x as f64 - ring[ n - 1 ] . x as f64 * ring[ 0 ] . y as f64 ;
611 for i in 1 ..n {
7- area += ring[ i - 1 ] . y * ring[ i] . x - ring[ i - 1 ] . x * ring[ i] . y ;
12+ area += ring[ i - 1 ] . y as f64 * ring[ i] . x as f64 - ring[ i - 1 ] . x as f64 * ring[ i] . y as f64 ;
813 }
914 // Note that in the shoelace formula you need to divide this result by 2 to get the actual area.
1015 // Here we skip this division because we only use this area formula to calculate the winding
You can’t perform that action at this time.
0 commit comments