diff --git a/lwrserv/include/Mat.h b/lwrserv/include/Mat.h index ce84336..7dbdd72 100644 --- a/lwrserv/include/Mat.h +++ b/lwrserv/include/Mat.h @@ -48,7 +48,14 @@ typedef Mat Mat4d; typedef Mat MatCarthesian; -// template square matrix class for SIMPLE data types +/** + * Matrix class for class and simple data types + * template with type and size of the vector + * + * @author Philipp Schoenberger + * @copyright 2012 philipp schoenberger All rights reserved. + * @license This project is released under the GNU Public License. + */ template class Mat { @@ -179,6 +186,7 @@ public: * within the array * * @param scalar the value to add + * @return the new calculated matrix */ Mat operator + (const T &scalar) { @@ -190,10 +198,11 @@ public: } /** - * operator to add a simple type to each entry + * operator to subtract a simple type to each entry * within the array * - * @param scalar the value to add + * @param scalar the value to subtract + * @return the new calculated matrix */ Mat operator - (const T &scalar) { @@ -205,10 +214,11 @@ public: } /** - * operator to add a simple type to each entry + * operator to multiply a simple type to each entry * within the array * - * @param scalar the value to add + * @param scalar the value to multiply the matrix cells + * @return the new calculated matrix */ Mat operator * (const T &scalar) { @@ -219,15 +229,28 @@ public: return buf; } + /** + * operator to divide a simple type to each entry + * within the array + * + * @param scalar the value to divide the matrix cells + * @return the new calculated matrix + */ Mat operator / (const T &scalar) { Mat buf; - for (unsigned int i=0; i operator * (const Mat &mat) { Mat buf; @@ -237,11 +260,21 @@ public: buf(i,j) += m_aatData[i][a] * mat(a,j); return buf; } + /** + * This functions is used for the assigning operator. + * for a simple array for the right hand side. + * The array has to be column wise coded. + * + * @info the template type has to provide the abs function + * + * @param aatData the right hand side array + * @return the new matrix + */ Mat &operator = (const T aatData[SIZE*SIZE]) { - for (unsigned int i=0; i norm() { T buf; @@ -294,14 +350,31 @@ public: return buf; } + /** + * This functions generates the transposed matrix for the + * current one. + * @return the transposed matrix + * + * @see transpose + * @see determinant + */ Mat transpose() { Mat buf; - for (unsigned int i=0; i inv() { T det = determinant(); @@ -316,12 +389,22 @@ public: return thisTransposed; } + /** + * This functions copies the vales from the matrix to a flat list + * of simple types. The order will be row wise. + * @param atData the flat destination array + */ void getData (T atData[SIZE*SIZE]) { for (unsigned int row=0; row static std::ostream& operator<< (std::ostream& output,const Mat &mat) { @@ -356,33 +448,47 @@ static std::ostream& operator<< (std::ostream& output,const Mat &mat) } return output; } + +/** + * This function creates a rotation matrix for a x-y-z rotation + * + * @param x rotation for the x axis in [ degree ] + * @param y rotation for the x axis in [ degree ] + * @param x rotation for the x axis in [ degree ] + * @return a homogeneous cartesian matrix + */ static Mat getRotationMatrix(float x_angle,float y_angle, float z_angle) { Mat tempx,tempy,tempz; + + // create x rotation float temp_x[4][4] = { { 1, 0, 0, 0}, { 0, cos(x_angle), -sin(x_angle), 0}, { 0, sin(x_angle), cos(x_angle), 0}, { 0, 0, 0, 1} }; + // create y rotation float temp_y[4][4] = { { cos(y_angle), 0, -sin(y_angle), 0}, { 0, 1, 0, 0}, { sin(y_angle), 0, cos(y_angle), 0}, { 0, 0, 0, 1} }; + + // create z rotation float temp_z[4][4] = { { cos(z_angle), -sin(z_angle), 0, 0}, { sin(z_angle), cos(z_angle), 0, 0}, { 0, 0, 1, 0}, { 0, 0, 0, 1} }; + // combine all rotations to a matrix class tempx=temp_x; tempy=temp_y; tempz=temp_z; return tempz*tempy*tempx; } /** - * @} * @} */ #endif diff --git a/lwrserv/include/Vec.h b/lwrserv/include/Vec.h index 4253bf1..02e341f 100644 --- a/lwrserv/include/Vec.h +++ b/lwrserv/include/Vec.h @@ -4,6 +4,35 @@ #include #include #include "Mat.h" +/** + * @addtogroup math + * @{ + * @author Philipp Schoenberger + * @version 2.0 + * + * @section LICENSE + * + * This program 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. + * + * This program 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 at + * https://www.gnu.org/copyleft/gpl.html + * + * @section DESCRIPTION + * + * This file contains the Trajectory for a linear trajectory + * The linear trajectory only uses the max speed and ignores + * the acceleration parameter. + * The movement is a strict hard acceleration and deacceration. + * + * The slowest joint is defining the speed of the other joints. + * By that all joints start and stop the movement synchronously + */ template class Vec; template class Mat; @@ -113,7 +142,7 @@ public: /** * assignment operator between vectors - * also capabile of muilti asignments + * also capable of multi assignments * e.g: * * vec1 = vec2 = vec3; @@ -139,6 +168,17 @@ public: return (*this); } + /** + * assignment operator between simple types + * also capable of multi assignments + * e.g: + * + * vec1 = vec2 = vec3; + * L-Value = R-Value/L-Value = R-Value + * + * @param atData the source data array which should be copied + * @retval returns the current + */ Vec &operator = (const T atData[SIZE]) { for (unsigned int i=0; i static std::ostream& operator<< (std::ostream& output,const Vec &vec) { @@ -404,4 +648,7 @@ static std::ostream& operator<< (std::ostream& output,const Vec &vec) return output; } +/** + * @} + */ #endif