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