[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24431] trunk/blender/source/blender/ blenlib: Math Lib Reorganization

Brecht Van Lommel brecht at blender.org
Mon Nov 9 23:42:41 CET 2009


Revision: 24431
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24431
Author:   blendix
Date:     2009-11-09 23:42:41 +0100 (Mon, 09 Nov 2009)

Log Message:
-----------
Math Lib Reorganization

* New header and source files.
* Still need a few tweaks before switching code to use them.

Added Paths:
-----------
    trunk/blender/source/blender/blenlib/BLI_math.h
    trunk/blender/source/blender/blenlib/BLI_math_base.h
    trunk/blender/source/blender/blenlib/BLI_math_color.h
    trunk/blender/source/blender/blenlib/BLI_math_geom.h
    trunk/blender/source/blender/blenlib/BLI_math_matrix.h
    trunk/blender/source/blender/blenlib/BLI_math_rotation.h
    trunk/blender/source/blender/blenlib/BLI_math_vector.h
    trunk/blender/source/blender/blenlib/intern/math_base.c
    trunk/blender/source/blender/blenlib/intern/math_color.c
    trunk/blender/source/blender/blenlib/intern/math_geom.c
    trunk/blender/source/blender/blenlib/intern/math_matrix.c
    trunk/blender/source/blender/blenlib/intern/math_rotation.c
    trunk/blender/source/blender/blenlib/intern/math_vector.c

Added: trunk/blender/source/blender/blenlib/BLI_math.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math.h	                        (rev 0)
+++ trunk/blender/source/blender/blenlib/BLI_math.h	2009-11-09 22:42:41 UTC (rev 24431)
@@ -0,0 +1,64 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: some of this file.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ * */
+
+#ifndef BLI_MATH
+#define BLI_MATH
+
+/* Abbreviations:
+ *
+ * fl = float
+ * db = double
+ * v2 = vec2 = vector 2
+ * v3 = vec3 = vector 3
+ * v4 = vec4 = vector 4
+ * qt = quat = quaternion
+ * dq = dquat = dual quaternion
+ * m2 = mat2 = matrix 2x2
+ * m3 = mat3 = matrix 3x3
+ * m4 = mat4 = matrix 4x4
+ * eul = euler rotation
+ * eulO = euler with order
+ *
+ * Variable Names:
+ *
+ * f = single value
+ * a, b, c = vectors
+ * r = result vector
+ * A, B, C = matrices
+ * R = result matrix
+ *
+ */
+
+#include "BLI_math_base.h"
+#include "BLI_math_color.h"
+#include "BLI_math_geom.h"
+#include "BLI_math_matrix.h"
+#include "BLI_math_rotation.h"
+#include "BLI_math_vector.h"
+
+#endif /* BLI_MATH */
+

Added: trunk/blender/source/blender/blenlib/BLI_math_base.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_base.h	                        (rev 0)
+++ trunk/blender/source/blender/blenlib/BLI_math_base.h	2009-11-09 22:42:41 UTC (rev 24431)
@@ -0,0 +1,156 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: some of this file.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ * */
+
+#ifndef BLI_MATH_BASE
+#define BLI_MATH_BASE
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef WIN32
+#define _USE_MATH_DEFINES
+#endif
+
+#include <math.h>
+
+#ifndef M_PI
+#define M_PI        3.14159265358979323846
+#endif
+#ifndef M_PI_2
+#define M_PI_2      1.57079632679489661923
+#endif
+#ifndef M_SQRT2
+#define M_SQRT2     1.41421356237309504880
+#endif
+#ifndef M_SQRT1_2
+#define M_SQRT1_2   0.70710678118654752440
+#endif
+#ifndef M_1_PI
+#define M_1_PI      0.318309886183790671538
+#endif
+#ifndef M_E
+#define M_E             2.7182818284590452354
+#endif
+#ifndef M_LOG2E
+#define M_LOG2E         1.4426950408889634074
+#endif
+#ifndef M_LOG10E
+#define M_LOG10E        0.43429448190325182765
+#endif
+#ifndef M_LN2
+#define M_LN2           0.69314718055994530942
+#endif
+#ifndef M_LN10
+#define M_LN10          2.30258509299404568402
+#endif
+
+#ifndef sqrtf
+#define sqrtf(a) ((float)sqrt(a))
+#endif
+#ifndef powf
+#define powf(a, b) ((float)pow(a, b))
+#endif
+#ifndef cosf
+#define cosf(a) ((float)cos(a))
+#endif
+#ifndef sinf
+#define sinf(a) ((float)sin(a))
+#endif
+#ifndef acosf
+#define acosf(a) ((float)acos(a))
+#endif
+#ifndef asinf
+#define asinf(a) ((float)asin(a))
+#endif
+#ifndef atan2f
+#define atan2f(a, b) ((float)atan2(a, b))
+#endif
+#ifndef tanf
+#define tanf(a) ((float)tan(a))
+#endif
+#ifndef atanf
+#define atanf(a) ((float)atan(a))
+#endif
+#ifndef floorf
+#define floorf(a) ((float)floor(a))
+#endif
+#ifndef ceilf
+#define ceilf(a) ((float)ceil(a))
+#endif
+#ifndef fabsf
+#define fabsf(a) ((float)fabs(a))
+#endif
+#ifndef logf
+#define logf(a) ((float)log(a))
+#endif
+#ifndef expf
+#define expf(a) ((float)exp(a))
+#endif
+#ifndef fmodf
+#define fmodf(a, b) ((float)fmod(a, b))
+#endif
+
+#ifdef WIN32
+#ifndef FREE_WINDOWS
+#define isnan(n) _isnan(n)
+#define finite _finite
+#endif
+#endif
+
+#ifndef SWAP
+#define SWAP(type, a, b)	{ type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
+#endif
+
+#ifndef CLAMP
+#define CLAMP(a, b, c)		if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c)
+#endif
+
+/******************************* Float ******************************/
+
+float sqrt3f(float f);
+double sqrt3d(double d);
+
+float saacosf(float f);
+float saasinf(float f);
+float sasqrtf(float f);
+float saacos(float fac);
+float saasin(float fac);
+float sasqrt(float fac);
+
+float interpf(float a, float b, float t);
+
+float power_of_2(float f);
+
+float shell_angle_to_dist(float angle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BLI_MATH_BASE */
+

Added: trunk/blender/source/blender/blenlib/BLI_math_color.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_color.h	                        (rev 0)
+++ trunk/blender/source/blender/blenlib/BLI_math_color.h	2009-11-09 22:42:41 UTC (rev 24431)
@@ -0,0 +1,66 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: some of this file.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ * */
+
+#ifndef BLI_MATH_COLOR
+#define BLI_MATH_COLOR
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BLI_CS_SMPTE	0
+#define BLI_CS_REC709	1
+#define BLI_CS_CIE		2
+
+/******************* Conversion to RGB ********************/
+
+void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b);
+void hex_to_rgb(char *hexcol, float *r, float *g, float *b);
+void yuv_to_rgb(float y, float u, float v, float *lr, float *lg, float *lb);
+void ycc_to_rgb(float y, float cb, float cr, float *lr, float *lg, float *lb);
+void xyz_to_rgb(float x, float y, float z, float *r, float *g, float *b, int colorspace);
+void cpack_to_rgb(unsigned int col, float *r, float *g, float *b);
+
+/***************** Conversion from RGB ********************/
+
+void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv);
+void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr);
+void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv);
+unsigned int rgb_to_cpack(float r, float g, float b);
+unsigned int hsv_to_cpack(float h, float s, float v);
+
+/************************** Other *************************/
+
+int constrain_rgb(float *r, float *g, float *b);
+void minmax_rgb(short c[3]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BLI_MATH_COLOR */
+

Added: trunk/blender/source/blender/blenlib/BLI_math_geom.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_geom.h	                        (rev 0)
+++ trunk/blender/source/blender/blenlib/BLI_math_geom.h	2009-11-09 22:42:41 UTC (rev 24431)
@@ -0,0 +1,157 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: some of this file.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ * */
+
+#ifndef BLI_MATH_GEOM
+#define BLI_MATH_GEOM
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/********************************** Polygons *********************************/
+
+void cent_tri_v3(float r[3], float a[3], float b[3], float c[3]);
+void cent_quad_v3(float r[3], float a[3], float b[3], float c[3], float d[3]);
+
+float normal_tri_v3(float r[3], float a[3], float b[3], float c[3]);
+float normal_quad_v3(float r[3], float a[3], float b[3], float c[3], float d[3]);
+
+float area_tri_v2(float a[2], float b[2], float c[2]);
+float area_tri_v3(float a[3], float b[3], float c[3]);
+float area_quad_v3(float a[3], float b[3], float c[3], float d[3]);
+float area_poly_v3(int nr, float *verts, float normal[3]); // TODO float verts[][3]
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list