FCLT#58797 Versie 4.18 Geen afrondfouten/oveflow bij Centroid berekening als zowel x en y rond INT_MAX
svn path=/Slnkdwf/trunk/; revision=43710
This commit is contained in:
@@ -276,11 +276,13 @@ Subject 1.02: How do I find the distance from a point to a line?
|
||||
int i;
|
||||
double area = 0;
|
||||
for (i=0;i<pg.count();i++) {
|
||||
const WT_Logical_Point &dwfPtA = pg.points()[i];
|
||||
const WT_Logical_Point &dwfPtB = pg.points()[(i + 1) % pg.count()];
|
||||
|
||||
area += (double)dwfPtA.m_x * dwfPtB.m_y;
|
||||
area -= (double)dwfPtA.m_y * dwfPtB.m_x;
|
||||
const int j = (i + 1) % pg.count();
|
||||
const double Xi = pg.points()[i].m_x, // Alles naar double anders krijgen wel overflows
|
||||
Yi = pg.points()[i].m_y,
|
||||
Xj = pg.points()[j].m_x,
|
||||
Yj = pg.points()[j].m_y;
|
||||
//area += Xi*Yj - Xj*Yi; // heeft bij X en Y beide rond INT_MAX zelfs met double afrondproblemen
|
||||
area += (Xi - Xj)*Yj + Xj*(Yj - Yi);
|
||||
}
|
||||
|
||||
area /= 2;
|
||||
@@ -337,10 +339,10 @@ WT_Logical_Point CSLNKContourImpl::LabelPosition(LABELPOS pos /*= LABEL_DEFAULT*
|
||||
double dDWFarea = 0; // Die ook meteen uitrekenen
|
||||
for (i = 0; i < pg.count(); i++) {
|
||||
j = (i + 1) % pg.count();
|
||||
double Xi=pg.points()[i].m_x, // Alles naar double anders krijgen wel overflows
|
||||
Yi=pg.points()[i].m_y,
|
||||
Xj=pg.points()[j].m_x,
|
||||
Yj=pg.points()[j].m_y;
|
||||
const double Xi = pg.points()[i].m_x, // Alles naar double anders krijgen wel overflows
|
||||
Yi = pg.points()[i].m_y,
|
||||
Xj = pg.points()[j].m_x,
|
||||
Yj = pg.points()[j].m_y;
|
||||
//double dArea = Xi*Yj - Xj*Yi; // heeft bij X en Y beide rond INT_MAX zelfs met double afrondproblemen
|
||||
double dArea = (Xi-Xj)*Yj + Xj*(Yj-Yi);
|
||||
dDWFarea += dArea;
|
||||
|
||||
Reference in New Issue
Block a user