4
* ***** BEGIN GPL LICENSE BLOCK *****
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21
* All rights reserved.
23
* The Original Code is: all of this file.
25
* Contributor(s): Marc Freixas, Ken Hughes
27
* ***** END GPL LICENSE BLOCK *****
30
/** \file boolop/intern/BOP_MathUtils.h
31
* \ingroup boolopintern
35
#ifndef __BOP_MATHUTILS_H__
36
#define __BOP_MATHUTILS_H__
40
#include "MT_Point3.h"
41
#include "MT_Plane3.h"
43
/* define this to give better precision comparisons */
47
const MT_Scalar BOP_EPSILON(1.0e-5);
49
const MT_Scalar BOP_EPSILON(9.3132257461547852e-10); /* ~= 2**-30 */
52
inline int BOP_sign(MT_Scalar x) {
53
return x < 0.0 ? -1 : x > 0.0 ? 1 : 0;
55
inline MT_Scalar BOP_abs(MT_Scalar x) { return fabs(x); }
56
int BOP_comp(const MT_Scalar A, const MT_Scalar B);
57
int BOP_comp(const MT_Tuple3& A, const MT_Tuple3& B);
58
int BOP_comp0(const MT_Scalar A);
59
inline bool BOP_fuzzyZero(MT_Scalar x) { return BOP_comp0(x) == 0; }
60
int BOP_exactComp(const MT_Scalar A, const MT_Scalar B);
61
int BOP_exactComp(const MT_Tuple3& A, const MT_Tuple3& B);
62
bool BOP_between(const MT_Point3& p1, const MT_Point3& p2, const MT_Point3& p3);
63
bool BOP_collinear(const MT_Point3& p1, const MT_Point3& p2, const MT_Point3& p3);
64
bool BOP_convex(const MT_Point3& p1, const MT_Point3& p2, const MT_Point3& p3,
66
int BOP_concave(const MT_Point3& p1, const MT_Point3& p2, const MT_Point3& p3, const MT_Point3& p4);
67
bool BOP_intersect(const MT_Vector3& vL1, const MT_Point3& pL1, const MT_Vector3& vL2,
68
const MT_Point3& pL2, MT_Point3& intersection);
69
bool BOP_getCircleCenter(const MT_Point3& p1, const MT_Point3& p2, const MT_Point3& p3,
70
const MT_Point3& center);
71
bool BOP_isInsideCircle(const MT_Point3& p1, const MT_Point3& p2, const MT_Point3& p3,
72
const MT_Point3& p4, const MT_Point3& p5);
73
bool BOP_isInsideCircle(const MT_Point3& p1, const MT_Point3& p2, const MT_Point3& p3,
75
MT_Scalar BOP_orientation(const MT_Plane3& p1, const MT_Plane3& p2);
76
int BOP_classify(const MT_Point3& p, const MT_Plane3& plane);
77
MT_Point3 BOP_intersectPlane(const MT_Plane3& plane, const MT_Point3& p1, const MT_Point3& p2);
78
bool BOP_containsPoint(const MT_Plane3& plane, const MT_Point3& point);
79
MT_Point3 BOP_4PointIntersect(const MT_Point3& p0, const MT_Point3& p1, const MT_Point3& p2,
81
MT_Scalar BOP_EpsilonDistance(const MT_Point3& p0, const MT_Point3& p1, const MT_Point3& q);