Blender V2.61 - r43446

mathutils_Matrix.h

Go to the documentation of this file.
00001 /* 
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): Joseph Gilbert
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  *
00027  */
00028 
00034 #ifndef MATHUTILS_MATRIX_H
00035 #define MATHUTILS_MATRIX_H
00036 
00037 extern PyTypeObject matrix_Type;
00038 extern PyTypeObject matrix_access_Type;
00039 #define MatrixObject_Check(_v) PyObject_TypeCheck((_v), &matrix_Type)
00040 #define MATRIX_MAX_DIM 4
00041 
00042 /* matrix[row][col] == MATRIX_ITEM_INDEX(matrix, row, col) */
00043 
00044 #ifdef DEBUG
00045 #  define MATRIX_ITEM_ASSERT(_mat, _row, _col) (BLI_assert(_row < (_mat)->num_row && _col < (_mat)->num_col))
00046 #else
00047 #  define MATRIX_ITEM_ASSERT(_mat, _row, _col) (void)0
00048 #endif
00049 
00050 #define MATRIX_ITEM_INDEX(_mat, _row, _col) (MATRIX_ITEM_ASSERT(_mat, _row, _col),(((_mat)->num_row * (_col)) + (_row)))
00051 #define MATRIX_ITEM_PTR(  _mat, _row, _col) ((_mat)->matrix + MATRIX_ITEM_INDEX(_mat, _row, _col))
00052 #define MATRIX_ITEM(      _mat, _row, _col) ((_mat)->matrix  [MATRIX_ITEM_INDEX(_mat, _row, _col)])
00053 
00054 #define MATRIX_COL_INDEX(_mat, _col) (MATRIX_ITEM_INDEX(_mat, 0, _col))
00055 #define MATRIX_COL_PTR(  _mat, _col) ((_mat)->matrix + MATRIX_COL_INDEX(_mat, _col))
00056 
00057 typedef struct {
00058     BASE_MATH_MEMBERS(matrix);
00059     unsigned short num_col;
00060     unsigned short num_row;
00061 } MatrixObject;
00062 
00063 /* struct data contains a pointer to the actual data that the
00064  * object uses. It can use either PyMem allocated data (which will
00065  * be stored in py_data) or be a wrapper for data allocated through
00066  * blender (stored in blend_data). This is an either/or struct not both */
00067 
00068 /* prototypes */
00069 PyObject *Matrix_CreatePyObject(float *mat,
00070                                 const unsigned short num_col, const unsigned short num_row,
00071                                 int type, PyTypeObject *base_type);
00072 PyObject *Matrix_CreatePyObject_cb(PyObject *user,
00073                                    const unsigned short num_col, const unsigned short num_row,
00074                                    int cb_type, int cb_subtype);
00075 
00076 extern int mathutils_matrix_row_cb_index; /* default */
00077 extern int mathutils_matrix_col_cb_index;
00078 extern int mathutils_matrix_translation_cb_index;
00079 
00080 extern struct Mathutils_Callback mathutils_matrix_row_cb; /* default */
00081 extern struct Mathutils_Callback mathutils_matrix_col_cb;
00082 extern struct Mathutils_Callback mathutils_matrix_translation_cb;
00083 
00084 void matrix_as_3x3(float mat[3][3], MatrixObject *self);
00085 
00086 #endif /* MATHUTILS_MATRIX_H */