summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2007-05-25 09:29:33 +0000
committerKore Nordmann <github@kore-nordmann.de>2007-05-25 09:29:33 +0000
commit40967187c4276d08ade3efc26ded4a46d5085199 (patch)
treeaa37712cc321868d5bfdf6fb58762eef5b15da64 /src
parent9d608ebc1f95c411add7ebdb3f4157d56ca9a7f9 (diff)
downloadzetacomponents-graph-40967187c4276d08ade3efc26ded4a46d5085199.zip
zetacomponents-graph-40967187c4276d08ade3efc26ded4a46d5085199.tar.gz
- Fixed issue #10846: Division by zero in polygon size reducement algorithm
for edges with an angle equals 0 degree.
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/driver.php25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/interfaces/driver.php b/src/interfaces/driver.php
index a477eea..cb8857a 100644
--- a/src/interfaces/driver.php
+++ b/src/interfaces/driver.php
@@ -117,9 +117,9 @@ abstract class ezcGraphDriver
}
$vectors[$i]->unify();
+ // Remove point from list if it the same as the next point
if ( ( $vectors[$i]->x == $vectors[$i]->y ) && ( $vectors[$i]->x == 0 ) )
{
- // Remove point from list if it the same as the next point
$pointCount--;
if ( $i === 0 )
{
@@ -136,6 +136,29 @@ abstract class ezcGraphDriver
}
}
+ // Remove vectors and appendant point, if local angle equals zero
+ // dergrees.
+ for ( $i = 0; $i < $pointCount; ++$i )
+ {
+ $nextPoint = ( $i + 1 ) % $pointCount;
+
+ if ( ( abs( $vectors[$i]->x - $vectors[$nextPoint]->x ) < .0001 ) &&
+ ( abs( $vectors[$i]->y - $vectors[$nextPoint]->y ) < .0001 ) )
+ {
+ $pointCount--;
+
+ $points = array_merge(
+ array_slice( $points, 0, $i + 1 ),
+ array_slice( $points, $i + 2 )
+ );
+ $vectors = array_merge(
+ array_slice( $vectors, 0, $i + 1 ),
+ array_slice( $vectors, $i + 2 )
+ );
+ $i--;
+ }
+ }
+
// No reducements for lines
if ( $pointCount <= 2 )
{
OpenPOWER on IntegriCloud