summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2011-03-02 13:07:26 +0000
committerJakob Odersky <jodersky@gmail.com>2011-03-02 13:07:26 +0000
commit7d1eed4fb0f38718d6623b9d2e8ff59499696d77 (patch)
treebddf8c760fe8011310d954a7a3d18798ad5dcc89 /src
parent25027cd43e3e7e67814bbcbdfbcf27c94da7319b (diff)
downloadvhc-7d1eed4fb0f38718d6623b9d2e8ff59499696d77.tar.gz
vhc-7d1eed4fb0f38718d6623b9d2e8ff59499696d77.tar.bz2
vhc-7d1eed4fb0f38718d6623b9d2e8ff59499696d77.zip
Created configuration file for doxygen `Doxyfile'. Modified Vector3.getUnit(), now throws exception when called on null vector.
Diffstat (limited to 'src')
-rw-r--r--src/vhc/Vector3.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/vhc/Vector3.h b/src/vhc/Vector3.h
index 4e827d0..5789968 100644
--- a/src/vhc/Vector3.h
+++ b/src/vhc/Vector3.h
@@ -11,6 +11,7 @@
#include <iostream>
#include <sstream>
#include <math.h>
+#include <stdexcept>
namespace vhc {
@@ -75,7 +76,10 @@ public:
double getLength() const {return sqrt(dot(*this));};
/** Unit vector parallel to this vector. */
- Vector3 getUnit() const {return (*this) / getLength();};
+ Vector3 getUnit() const {
+ if (getLength() != 0.0) return (*this) / getLength();
+ else throw std::domain_error("Unit vector.");
+ };
/** Returns a string representation of this vector. */
std::string toString() const {