Re-adding
[lsystem3d.git] / src / vector.h
diff --git a/src/vector.h b/src/vector.h
new file mode 100644 (file)
index 0000000..df1e758
--- /dev/null
@@ -0,0 +1,84 @@
+// Copyright (C) 2006 Erik Dahlberg
+// 
+// This file is part of LSystem3d.
+// 
+// LSystem3D is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+// 
+// LSystem3D is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with LSystem3D; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+
+
+
+#ifndef VECTOR_H
+#define VECTOR_H
+
+#include "coordinate.h"
+
+
+
+/**
+ * 3d vector
+ */
+class Vector : public Coordinate
+{
+public:
+    /**
+     * Constructor
+     * @param x the x-coordinate
+     * @param y the y-coordinate
+     * @param z the z-coordinate
+     */
+    Vector(double x = 0.0, double y = 1.0, double z = 0.0);
+    
+    /**
+     * Destructor
+     */
+    ~Vector();
+    
+    /**
+     * Rotate around another vector
+     * @param angle rotation angle
+     * @param vector arbitrary vector to rotate around
+     */
+    void rotate(double angle, Vector vector);
+    
+    /**
+     * Normalize vector
+     */
+    void normalize();
+    
+    /**
+     * Get scalar product of the vectors
+     * @param vector arbitrary vector
+     * @return the scalar product
+     */
+    double getScalarProduct(Vector vector);
+    
+    /**
+     * Get cross product of the vectors
+     * @param vector arbitrary vector
+     * @return the cross product
+     */
+    Vector getCrossProduct(Vector vector);
+    
+    /**
+     * Get angle between the vectors
+     * @param vector the second (normalized) vector
+     * @return the angle, in degrees
+     */
+    double getAngle(Vector vector);
+};
+
+
+
+#endif