Blender  V2.59
Functions
BOP_MathUtils.cpp File Reference
#include "BOP_MathUtils.h"
#include <iostream>

Go to the source code of this file.

Functions

int BOP_comp (const MT_Scalar A, const MT_Scalar B)
int BOP_comp0 (const MT_Scalar A)
int BOP_comp (const MT_Tuple3 &A, const MT_Tuple3 &B)
int BOP_exactComp (const MT_Scalar A, const MT_Scalar B)
int BOP_exactComp (const MT_Tuple3 &A, const MT_Tuple3 &B)
bool BOP_between (const MT_Point3 &p1, const MT_Point3 &p2, const MT_Point3 &p3)
bool BOP_collinear (const MT_Point3 &p1, const MT_Point3 &p2, const MT_Point3 &p3)
bool BOP_convex (const MT_Point3 &p1, const MT_Point3 &p2, const MT_Point3 &p3, const MT_Point3 &p4)
int BOP_concave (const MT_Point3 &p1, const MT_Point3 &p2, const MT_Point3 &p3, const MT_Point3 &p4)
bool BOP_intersect (const MT_Vector3 &vL1, const MT_Point3 &pL1, const MT_Vector3 &vL2, const MT_Point3 &pL2, MT_Point3 &intersection)
bool BOP_getCircleCenter (const MT_Point3 &p1, const MT_Point3 &p2, const MT_Point3 &p3, MT_Point3 &center)
bool BOP_isInsideCircle (const MT_Point3 &p1, const MT_Point3 &p2, const MT_Point3 &p3, const MT_Point3 &q)
bool BOP_isInsideCircle (const MT_Point3 &p1, const MT_Point3 &p2, const MT_Point3 &p3, const MT_Point3 &p4, const MT_Point3 &p5)
MT_Scalar BOP_orientation (const MT_Plane3 &p1, const MT_Plane3 &p2)
int BOP_classify (const MT_Point3 &p, const MT_Plane3 &plane)
MT_Point3 BOP_intersectPlane (const MT_Plane3 &plane, const MT_Point3 &p1, const MT_Point3 &p2)
bool BOP_containsPoint (const MT_Plane3 &plane, const MT_Point3 &point)
MT_Point3 BOP_4PointIntersect (const MT_Point3 &p0, const MT_Point3 &p1, const MT_Point3 &p2, const MT_Point3 &q)
MT_Scalar BOP_EpsilonDistance (const MT_Point3 &p0, const MT_Point3 &p1, const MT_Point3 &q)

Detailed Description

Definition in file BOP_MathUtils.cpp.


Function Documentation

MT_Point3 BOP_4PointIntersect ( const MT_Point3 p0,
const MT_Point3 p1,
const MT_Point3 p2,
const MT_Point3 q 
)

Pre: p0, p1 and p2 is a triangle and q is an interior point.

Parameters:
p0point
p1point
p2point
qpoint
Returns:
intersection point I v (p0)-----(I)----->(p1) \ ^ / \ |w / \ | / \ (q) / \ | / \ | / \ | / (p2)

v = P1-P2 w = P3-Q r0(t) = v*t+P1 r1(t) = w*t+P3 I = r0^r1

Definition at line 440 of file BOP_MathUtils.cpp.

References BOP_intersect(), I, simple_enum_gen::w, MT_Tuple3::x(), MT_Tuple3::y(), and MT_Tuple3::z().

bool BOP_between ( const MT_Point3 p1,
const MT_Point3 p2,
const MT_Point3 p3 
)

Returns if p1 is between p2 and p3 and lay on the same line (are collinears).

Parameters:
p1point
p2point
p3point
Returns:
true if p1 is between p2 and p3 and lay on the same line, false otherwise

Definition at line 143 of file BOP_MathUtils.cpp.

References BOP_collinear(), and MT_Point3::distance().

int BOP_classify ( const MT_Point3 p,
const MT_Plane3 plane 
)

Classifies a point according to the specified plane with EPSILON accuracy.

Parameters:
ppoint
planeplane
Returns:
>0 if the point is above (OUT), =0 if the point is on (ON), <0 if the point is below (IN)

Definition at line 368 of file BOP_MathUtils.cpp.

References BOP_comp0(), and MT_Plane3::signedDistance().

Referenced by BOP_concave(), BOP_convex(), BOP_overlap(), BOP_splitFace(), and BOP_BSPNode::testPoint().

bool BOP_collinear ( const MT_Point3 p1,
const MT_Point3 p2,
const MT_Point3 p3 
)

Returns if three points lay on the same line (are collinears).

Parameters:
p1point
p2point
p3point
Returns:
true if the three points lay on the same line, false otherwise

Definition at line 156 of file BOP_MathUtils.cpp.

References BOP_comp(), BOP_fuzzyZero(), MT_Vector3::cross(), MT_Vector3::normalize(), simple_enum_gen::w, MT_Tuple3::x(), MT_Tuple3::y(), and MT_Tuple3::z().

Referenced by BOP_between(), BOP_mergeVertexs(), and clean_nonmanifold().

int BOP_comp ( const MT_Scalar  A,
const MT_Scalar  B 
)

Compares two scalars with EPSILON accuracy.

Parameters:
Ascalar
Bscalar
Returns:
1 if A > B, -1 if A < B, 0 otherwise

Definition at line 46 of file BOP_MathUtils.cpp.

References BOP_EPSILON().

Referenced by BOP_collinear(), BOP_comp(), BOP_getNearestVertex(), BOP_isInsideCircle(), and BOP_BBox::intersect().

int BOP_comp ( const MT_Tuple3 A,
const MT_Tuple3 B 
)

Compares two scalar triplets with EPSILON accuracy.

Parameters:
Ascalar triplet
Bscalar triplet
Returns:
1 if A > B, -1 if A < B, 0 otherwise

Definition at line 88 of file BOP_MathUtils.cpp.

References BOP_comp(), BOP_EPSILON(), MT_Tuple3::x(), MT_Tuple3::y(), and MT_Tuple3::z().

int BOP_comp0 ( const MT_Scalar  A)

Compares a scalar with EPSILON accuracy.

Parameters:
Ascalar
Returns:
1 if A > 0, -1 if A < 0, 0 otherwise

Definition at line 75 of file BOP_MathUtils.cpp.

References BOP_EPSILON().

Referenced by BOP_classify(), and BOP_fuzzyZero().

int BOP_concave ( const MT_Point3 p1,
const MT_Point3 p2,
const MT_Point3 p3,
const MT_Point3 p4 
)

Returns if a quad (coplanar) is concave and where is the split edge.

Returns:
0 if is convex, 1 if is concave and split edge is p1-p3 and -1 if is cancave and split edge is p2-p4.

Definition at line 200 of file BOP_MathUtils.cpp.

References BOP_classify(), and MT_Vector3::cross().

Referenced by BOP_splitQuad().

bool BOP_containsPoint ( const MT_Plane3 plane,
const MT_Point3 point 
)

Returns if a plane contains a point with EPSILON accuracy.

Parameters:
planeplane
pointpoint
Returns:
true if the point is on the plane, false otherwise

Definition at line 411 of file BOP_MathUtils.cpp.

References BOP_fuzzyZero(), and MT_Plane3::signedDistance().

Referenced by BOP_Face2Face(), BOP_removeOverlappedFaces(), and BOP_sew().

bool BOP_convex ( const MT_Point3 p1,
const MT_Point3 p2,
const MT_Point3 p3,
const MT_Point3 p4 
)

Returns if a quad (coplanar) is convex.

Returns:
true if the quad is convex, false otherwise

Definition at line 178 of file BOP_MathUtils.cpp.

References BOP_classify(), and MT_Vector3::cross().

MT_Scalar BOP_EpsilonDistance ( const MT_Point3 p0,
const MT_Point3 p1,
const MT_Point3 q 
)

Pre: p0, p1 and q are collinears.

Parameters:
p0point
p1point
qpoint
Returns:
0 if q == p0, 1 if q == p1, or a value between 0 and 1 otherwise

(p0)-----(q)------------(p1) |<-d1-->| | |<---------d0---------->|

Definition at line 463 of file BOP_MathUtils.cpp.

References BOP_fuzzyZero(), simple_enum_gen::d, and MT_Point3::distance().

int BOP_exactComp ( const MT_Scalar  A,
const MT_Scalar  B 
)

Compares two scalars strictly.

Parameters:
Ascalar
Bscalar
Returns:
1 if A > B, -1 if A < B, 0 otherwise

Definition at line 113 of file BOP_MathUtils.cpp.

int BOP_exactComp ( const MT_Tuple3 A,
const MT_Tuple3 B 
)

Compares two scalar strictly.

Parameters:
Ascalar triplet
Bscalar triplet
Returns:
1 if A > B, -1 if A < B, 0 otherwise

Definition at line 125 of file BOP_MathUtils.cpp.

References MT_Tuple3::x(), MT_Tuple3::y(), and MT_Tuple3::z().

bool BOP_getCircleCenter ( const MT_Point3 p1,
const MT_Point3 p2,
const MT_Point3 p3,
MT_Point3 center 
)

Returns the center of the circle defined by three points.

Parameters:
p1point
p2point
p3point
centercircle center
Returns:
false if points are collinears, true otherwise

Definition at line 268 of file BOP_MathUtils.cpp.

References BOP_intersect(), MT_Vector3::cross(), MT_Vector3::length(), MT_Point3::lerp(), MT_fuzzyZero(), MT_Plane3::Normal(), and MT_Vector3::normalize().

Referenced by BOP_isInsideCircle().

bool BOP_intersect ( const MT_Vector3 vL1,
const MT_Point3 pL1,
const MT_Vector3 vL2,
const MT_Point3 pL2,
MT_Point3 intersection 
)

Computes the intersection between two lines (on the same plane).

Parameters:
vL1first line vector
pL1first line point
vL2second line vector
pL2second line point
intersectionintersection point (if exists)
Returns:
false if lines are parallels, true otherwise

Definition at line 227 of file BOP_MathUtils.cpp.

References BOP_fuzzyZero(), MT_Tuple3::setValue(), MT_Tuple3::x(), MT_Tuple3::y(), and MT_Tuple3::z().

Referenced by BOP_4PointIntersect(), and BOP_getCircleCenter().

MT_Point3 BOP_intersectPlane ( const MT_Plane3 plane,
const MT_Point3 p1,
const MT_Point3 p2 
)

Intersects a plane with the line that contains the specified points.

Parameters:
planesplit plane
p1first line point
p2second line point
Returns:
intersection between plane and line that contains p1 and p2

Definition at line 381 of file BOP_MathUtils.cpp.

References MT_Tuple3::setValue(), MT_Tuple4::w(), MT_Tuple3::x(), MT_Tuple4::x(), MT_Tuple3::y(), MT_Tuple4::y(), MT_Tuple3::z(), and MT_Tuple4::z().

Referenced by BOP_BSPNode::addFace(), BOP_splitEdge(), BOP_BSPNode::classifyFace(), and BOP_BSPNode::splitTriangle().

bool BOP_isInsideCircle ( const MT_Point3 p1,
const MT_Point3 p2,
const MT_Point3 p3,
const MT_Point3 q 
)

Returns if points q is inside the circle defined by p1, p2 and p3.

Parameters:
p1point
p2point
p3point
qpoint
Returns:
true if p4 or p5 are inside the circle, false otherwise. If the circle does not exist (p1, p2 and p3 are collinears) returns true

Definition at line 309 of file BOP_MathUtils.cpp.

References BOP_comp(), BOP_getCircleCenter(), simple_enum_gen::d, and MT_Point3::distance().

Referenced by BOP_getTriangleVertex(), BOP_isInsideCircle(), BOP_splitQuad(), BOP_triangulateC(), and BOP_BSPNode::classifyFace().

bool BOP_isInsideCircle ( const MT_Point3 p1,
const MT_Point3 p2,
const MT_Point3 p3,
const MT_Point3 p4,
const MT_Point3 p5 
)

Returns if points p4 or p5 is inside the circle defined by p1, p2 and p3.

Parameters:
p1point
p2point
p3point
p4point
p5point
Returns:
true if p4 or p5 is inside the circle, false otherwise. If the circle does not exist (p1, p2 and p3 are collinears) returns true

Definition at line 335 of file BOP_MathUtils.cpp.

References BOP_comp(), BOP_getCircleCenter(), and MT_Point3::distance().

MT_Scalar BOP_orientation ( const MT_Plane3 p1,
const MT_Plane3 p2 
)

Returns if two planes share the same orientation.

Returns:
>0 if planes share the same orientation

Definition at line 354 of file BOP_MathUtils.cpp.

References MT_Tuple4::x(), MT_Tuple4::y(), and MT_Tuple4::z().

Referenced by BOP_Face2Face(), BOP_sew(), BOP_splitQuad(), and BOP_BSPNode::hasSameOrientation().