diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2007-02-01 12:19:17 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2007-02-01 12:19:17 +0000 |
commit | fbe8284433d09070d388c226d07d024f63fa6464 (patch) | |
tree | f9e1d9aa56e8af6d8139118c0e1ceaa9cec0ed94 /src/math | |
parent | ecef8638e0f565059960214f384430b07ce723a2 (diff) | |
download | zetacomponents-graph-fbe8284433d09070d388c226d07d024f63fa6464.zip zetacomponents-graph-fbe8284433d09070d388c226d07d024f63fa6464.tar.gz |
. Test unify for vector with zero length
Diffstat (limited to 'src/math')
-rw-r--r-- | src/math/vector.php | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/math/vector.php b/src/math/vector.php index f6f7af5..c8ff3bc 100644 --- a/src/math/vector.php +++ b/src/math/vector.php @@ -54,7 +54,7 @@ class ezcGraphVector extends ezcGraphCoordinate $length = $this->length(); if ( $length == 0 ) { - return false; + return $this; } $this->x /= $length; @@ -115,10 +115,16 @@ class ezcGraphVector extends ezcGraphCoordinate $vector = ezcGraphVector::fromCoordinate( $vector ); } - return acos( - $this->mul( $vector ) / - ( $this->length() * $vector->length() ) - ); + $factor = $this->length() * $vector->length(); + + if ( $factor == 0 ) + { + return false; + } + else + { + return acos( $this->mul( $vector ) / $factor ); + } } /** |