Blender V2.61 - r43446

BOP_MathUtils.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): Marc Freixas, Ken Hughes
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 
00035 #ifndef BOP_MATHUTILS_H
00036 #define BOP_MATHUTILS_H
00037 
00038 #include <math.h>
00039 #include <float.h>
00040 #include "MT_Point3.h"
00041 #include "MT_Plane3.h"
00042 
00043 /* define this to give better precision comparisons */
00044 #define VAR_EPSILON
00045 
00046 #ifndef VAR_EPSILON
00047 const MT_Scalar BOP_EPSILON(1.0e-5);
00048 #else
00049 const MT_Scalar BOP_EPSILON(9.3132257461547852e-10);    /* ~= 2**-30 */
00050 #endif
00051 
00052 inline int BOP_sign(MT_Scalar x) {
00053     return x < 0.0 ? -1 : x > 0.0 ? 1 : 0;
00054 }
00055 inline MT_Scalar BOP_abs(MT_Scalar x) { return fabs(x); }
00056 int BOP_comp(const MT_Scalar A, const MT_Scalar B);
00057 int BOP_comp(const MT_Tuple3& A, const MT_Tuple3& B);
00058 int BOP_comp0(const MT_Scalar A);
00059 inline bool BOP_fuzzyZero(MT_Scalar x) { return BOP_comp0(x) == 0; }
00060 int BOP_exactComp(const MT_Scalar A, const MT_Scalar B);
00061 int BOP_exactComp(const MT_Tuple3& A, const MT_Tuple3& B);
00062 bool BOP_between(const MT_Point3& p1, const MT_Point3& p2, const MT_Point3& p3);
00063 bool BOP_collinear(const MT_Point3& p1, const MT_Point3& p2, const MT_Point3& p3);
00064 bool BOP_convex(const MT_Point3& p1, const MT_Point3& p2, const MT_Point3& p3, 
00065                 const MT_Point3& p4);
00066 int BOP_concave(const MT_Point3& p1, const MT_Point3& p2, const MT_Point3& p3, const MT_Point3& p4);
00067 bool BOP_intersect(const MT_Vector3& vL1, const MT_Point3& pL1, const MT_Vector3& vL2, 
00068                    const MT_Point3& pL2, MT_Point3& intersection);
00069 bool BOP_getCircleCenter(const MT_Point3& p1, const MT_Point3& p2, const MT_Point3& p3, 
00070                          const MT_Point3& center);
00071 bool BOP_isInsideCircle(const MT_Point3& p1, const MT_Point3& p2, const MT_Point3& p3, 
00072                         const MT_Point3& p4, const MT_Point3& p5);
00073 bool BOP_isInsideCircle(const MT_Point3& p1, const MT_Point3& p2, const MT_Point3& p3, 
00074                         const MT_Point3& q);
00075 MT_Scalar BOP_orientation(const MT_Plane3& p1, const MT_Plane3& p2);
00076 int BOP_classify(const MT_Point3& p, const MT_Plane3& plane);
00077 MT_Point3 BOP_intersectPlane(const MT_Plane3& plane, const MT_Point3& p1, const MT_Point3& p2);
00078 bool BOP_containsPoint(const MT_Plane3& plane, const MT_Point3& point);
00079 MT_Point3 BOP_4PointIntersect(const MT_Point3& p0, const MT_Point3& p1, const MT_Point3& p2, 
00080                               const MT_Point3& q);
00081 MT_Scalar BOP_EpsilonDistance(const MT_Point3& p0, const MT_Point3& p1, const MT_Point3& q);
00082 
00083 #endif