X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=lsystem3d%2Fsrc%2Fvector.h;fp=lsystem3d%2Fsrc%2Fvector.h;h=df1e758c23aafe93f53861edd550a4337de9e53a;hb=e5247a3b88c449937af08f46afc271afda2954a2;hp=0000000000000000000000000000000000000000;hpb=c48a55e9e62ed7a9d46e3c6a53faae4bc05856e5;p=lsystem3d.git diff --git a/lsystem3d/src/vector.h b/lsystem3d/src/vector.h new file mode 100644 index 0000000..df1e758 --- /dev/null +++ b/lsystem3d/src/vector.h @@ -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