transfo.h 3.67 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2 3
/*******************************************************************************
 * CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
 * version 0.1                                                                  *
4
 * Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
Pierre Kraemer's avatar
Pierre Kraemer committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *                                                                              *
 * This library is free software; you can redistribute it and/or modify it      *
 * under the terms of the GNU Lesser General Public License as published by the *
 * Free Software Foundation; either version 2.1 of the License, or (at your     *
 * option) any later version.                                                   *
 *                                                                              *
 * This library 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 Lesser General Public License  *
 * for more details.                                                            *
 *                                                                              *
 * You should have received a copy of the GNU Lesser General Public License     *
 * along with this library; if not, write to the Free Software Foundation,      *
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
 *                                                                              *
20
 * Web site: http://cgogn.unistra.fr/                                           *
Pierre Kraemer's avatar
Pierre Kraemer committed
21 22 23 24
 * Contact information: cgogn@unistra.fr                                        *
 *                                                                              *
 *******************************************************************************/

25 26
#ifndef __TRANSFO__H__
#define __TRANSFO__H__
Pierre Kraemer's avatar
Pierre Kraemer committed
27 28 29 30 31 32

#include "Geometry/matrix.h"
#include <cmath>

namespace CGoGN
{
33

Pierre Kraemer's avatar
Pierre Kraemer committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
namespace Geom
{

/**
 * Apply a scale to matrix
 * @param sx scale in x axis
 * @param sy scale in y axis
 * @param sz scale in z axis
 * @param mat current matrix
 */
template <typename T>
void scale(T sx, T sy, T sz, Matrix<4,4,T>& mat);

/**
 * Apply a translation to matrix
 * @param tx scale in x axis
 * @param ty scale in y axis
 * @param tz scale in z axis
 * @param mat current matrix
 */
template <typename T>
void translate(T tx, T ty, T tz, Matrix<4,4,T>& mat);

/**
58
 * Apply a rotation around Z axis to matrix
Pierre Kraemer's avatar
Pierre Kraemer committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
 * @param angle angle of rotation in radian
 * @param mat current matrix
 */
template <typename T>
void rotateZ(T angle, Matrix<4,4,T>& mat);

/**
 * Apply a rotation around Y axis to matrix
 * @param angle angle of rotation in radian
 * @param mat current matrix
 */
template <typename T>
void rotateY(T angle, Matrix<4,4,T>& mat);

/**
 * Apply a rotation around X axis to matrix
 * @param angle angle of rotation in radian
 * @param mat current matrix
 */
template <typename T>
void rotateX(T angle, Matrix<4,4,T>& mat);

/**
 * Apply a rotation around axis to matrix
 * @param axis_x axis x coord
 * @param axis_y axis y coord
 * @param axis_z axis z coord
 * @param angle angle of rotation in radian
 * @param mat current matrix
 */
template <typename T>
void rotate(T axis_x, T axis_y, T axis_z, T angle, Matrix<4,4,T>& mat);

92 93 94
template <typename T>
void rotate(Vector<3,T>& axis, T angle, Matrix<4,4,T>& mat);

Pierre Kraemer's avatar
Pierre Kraemer committed
95 96 97 98 99 100
/**
 * Apply a transformation (stored in matrix) to a 3D point
 * @param P the point to transfo
 * @param mat the transformation matrix
 */
template <typename T>
Pierre Kraemer's avatar
Pierre Kraemer committed
101
Vector<3,T> transform(const Vector<3,T>& P, const Matrix<4,4,T>& mat);
Pierre Kraemer's avatar
Pierre Kraemer committed
102

103 104 105
} // namespace Geom

} // namespace CGoGN
Pierre Kraemer's avatar
Pierre Kraemer committed
106

107
#include "Geometry/transfo.hpp"
Pierre Kraemer's avatar
Pierre Kraemer committed
108 109

#endif