summaryrefslogtreecommitdiffstats
path: root/src/interfaces
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2007-04-03 08:24:43 +0000
committerKore Nordmann <github@kore-nordmann.de>2007-04-03 08:24:43 +0000
commitf23c6326d5f71bf434827c48d02f6d41906eea2f (patch)
treea7398844ba4fd3f9adc43f8d652079670b9ec0a2 /src/interfaces
parentd96fa2d3668219a4105e986b3b75dd69a0d8ff37 (diff)
downloadzetacomponents-graph-f23c6326d5f71bf434827c48d02f6d41906eea2f.zip
zetacomponents-graph-f23c6326d5f71bf434827c48d02f6d41906eea2f.tar.gz
- Optimized algorithm for polygon size reducement
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/driver.php35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/interfaces/driver.php b/src/interfaces/driver.php
index 354050f..ef7f57a 100644
--- a/src/interfaces/driver.php
+++ b/src/interfaces/driver.php
@@ -135,6 +135,27 @@ abstract class ezcGraphDriver
return $points;
}
+ // Determine one of the angles - we need to know where the smaller
+ // angle is, to determine if the inner side of the polygon is on
+ // the left or right hand.
+ //
+ // This is a valid simplification for ezcGraph(, for now).
+ //
+ // The sign of the scalar products results indicates on which site
+ // the smaller angle is, when comparing the orthogonale vector of
+ // one of the vectors with the other. Why? .. use pen and paper ..
+ //
+ // It is sufficant to do this once before iterating over the points,
+ // because the inner side of the polygon is on the same side of the
+ // point for each point.
+ $last = 0;
+ $next = 1;
+
+ $sign = (
+ -$vectors[$last]->y * $vectors[$next]->x +
+ $vectors[$last]->x * $vectors[$next]->y
+ ) < 0 ? 1 : -1;
+
// Move points to center
$newPoints = array();
for ( $i = 0; $i < $pointCount; ++$i )
@@ -142,20 +163,6 @@ abstract class ezcGraphDriver
$last = $i;
$next = ( $i + 1 ) % $pointCount;
- // Determine one of the angles - we need to know where the smaller
- // angle is, to determine if the inner side of the polygon is on
- // the left or right hand.
- //
- // This is a valid simplification for ezcGraph(, for now).
- //
- // The sign of the scalar products results indicates on which site
- // the smaller angle is, when comparing the orthogonale vector of
- // one of the vectors with the other. Why? .. use pen and paper ..
- $sign = (
- -$vectors[$last]->y * $vectors[$next]->x +
- $vectors[$last]->x * $vectors[$next]->y
- ) < 0 ? 1 : -1;
-
// Orthogonal vector with direction based on the side of the inner
// angle
$v = clone $vectors[$next];
OpenPOWER on IntegriCloud