Catch bug of negative fin area weight
This commit is contained in:
parent
7ffaabcda4
commit
458a5a0605
@ -644,7 +644,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
|
|
||||||
// calculate marginal area
|
// calculate marginal area
|
||||||
final double delta_x = (cur.x - prev.x);
|
final double delta_x = (cur.x - prev.x);
|
||||||
final double y_avg = (cur.y + prev.y)*0.5;
|
final double y_avg = (cur.y + prev.y)*0.5; // TODO: MEDIUM: what if one of the points is below the x-axis? (can produce negative area)
|
||||||
double area_increment = delta_x*y_avg;
|
double area_increment = delta_x*y_avg;
|
||||||
if( MathUtil.equals( 0, area_increment)){
|
if( MathUtil.equals( 0, area_increment)){
|
||||||
prev = cur;
|
prev = cur;
|
||||||
@ -663,6 +663,11 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
prev=cur;
|
prev=cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Negative weight => make positive. TODO: This is NOT a correct solution, but at least it won't throw an exception...
|
||||||
|
if (centroidSum.weight < 0) {
|
||||||
|
centroidSum = new Coordinate(centroidSum.x, -centroidSum.y, centroidSum.z, Math.abs(centroidSum.weight));
|
||||||
|
}
|
||||||
|
|
||||||
return centroidSum;
|
return centroidSum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user