1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- 2 * 3 * Copyright (C) 2010-2012 Richard Hughes <richard@hughsie.com> 4 * 5 * Licensed under the GNU Lesser General Public License Version 2.1 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #ifndef __CD_MATH_H__ 23 #define __CD_MATH_H__ 24 25 #define __CD_MATH_H_INSIDE__ 26 27 typedef struct { 28 gdouble m00, m01, m02; 29 gdouble m10, m11, m12; 30 gdouble m20, m21, m22; 31 /* any addition fields go *after* the data */ 32 } CdMat3x3; 33 34 typedef struct { 35 double v0, v1, v2; 36 /* any addition fields go *after* the data */ 37 } CdVec3; 38 39 void cd_vec3_clear (CdVec3 *src); 40 void cd_vec3_add (const CdVec3 *src1, 41 const CdVec3 *src2, 42 CdVec3 *dest); 43 void cd_vec3_subtract (const CdVec3 *src1, 44 const CdVec3 *src2, 45 CdVec3 *dest); 46 void cd_vec3_scalar_multiply (const CdVec3 *src, 47 gdouble value, 48 CdVec3 *dest); 49 void cd_vec3_copy (const CdVec3 *src, 50 CdVec3 *dest); 51 gdouble cd_vec3_squared_error (const CdVec3 *src1, 52 const CdVec3 *src2) 53 G_GNUC_WARN_UNUSED_RESULT; 54 gchar *cd_vec3_to_string (const CdVec3 *src); 55 gdouble *cd_vec3_get_data (const CdVec3 *src); 56 void cd_vec3_init (CdVec3 *dest, 57 gdouble v0, 58 gdouble v1, 59 gdouble v2); 60 void cd_mat33_init (CdMat3x3 *dest, 61 gdouble m00, 62 gdouble m01, 63 gdouble m02, 64 gdouble m10, 65 gdouble m11, 66 gdouble m12, 67 gdouble m20, 68 gdouble m21, 69 gdouble m22); 70 void cd_mat33_clear (const CdMat3x3 *src); 71 gchar *cd_mat33_to_string (const CdMat3x3 *src); 72 gdouble *cd_mat33_get_data (const CdMat3x3 *src); 73 void cd_mat33_set_identity (CdMat3x3 *src); 74 void cd_mat33_scalar_multiply (const CdMat3x3 *mat_src, 75 gdouble value, 76 CdMat3x3 *mat_dest); 77 void cd_mat33_vector_multiply (const CdMat3x3 *mat_src, 78 const CdVec3 *vec_src, 79 CdVec3 *vec_dest); 80 void cd_mat33_matrix_multiply (const CdMat3x3 *mat_src1, 81 const CdMat3x3 *mat_src2, 82 CdMat3x3 *mat_dest); 83 gboolean cd_mat33_reciprocal (const CdMat3x3 *src, 84 CdMat3x3 *dest); 85 gdouble cd_mat33_determinant (const CdMat3x3 *src) 86 G_GNUC_WARN_UNUSED_RESULT; 87 void cd_mat33_normalize (const CdMat3x3 *src, 88 CdMat3x3 *dest); 89 void cd_mat33_copy (const CdMat3x3 *src, 90 CdMat3x3 *dest); 91 92 #undef __CD_MATH_H_INSIDE__ 93 94 #endif /* __CD_MATH_H__ */ 95 96