Blender V2.61 - r43446
|
#include "gim_linear_math.h"
Go to the source code of this file.
Defines | |
#define | PLANEDIREPSILON 0.0000001f |
#define | PARALELENORMALS 0.000001f |
#define | TRIANGLE_NORMAL(v1, v2, v3, n) |
#define | TRIANGLE_NORMAL_FAST(v1, v2, v3, n) |
#define | TRIANGLE_PLANE(v1, v2, v3, plane) |
plane is a vec4f | |
#define | TRIANGLE_PLANE_FAST(v1, v2, v3, plane) |
plane is a vec4f | |
#define | EDGE_PLANE(e1, e2, n, plane) |
Calc a plane from an edge an a normal. plane is a vec4f. | |
#define | DISTANCE_PLANE_POINT(plane, point) (VEC_DOT(plane,point) - plane[3]) |
#define | PROJECT_POINT_PLANE(point, plane, projected) |
#define | PLANE_MINOR_AXES(plane, i0, i1) VEC_MINOR_AXES(plane, i0, i1) |
Finds the 2 smallest cartesian coordinates of a plane normal. | |
Enumerations | |
enum | ePLANE_INTERSECTION_TYPE { G_BACK_PLANE = 0, G_COLLIDE_PLANE, G_FRONT_PLANE } |
enum | eLINE_PLANE_INTERSECTION_TYPE { G_FRONT_PLANE_S1 = 0, G_FRONT_PLANE_S2, G_BACK_PLANE_S1, G_BACK_PLANE_S2, G_COLLIDE_PLANE_S1, G_COLLIDE_PLANE_S2 } |
Functions | |
template<typename CLASS_POINT , typename CLASS_PLANE > | |
SIMD_FORCE_INLINE bool | POINT_IN_HULL (const CLASS_POINT &point, const CLASS_PLANE *planes, GUINT plane_count) |
Verifies if a point is in the plane hull. | |
template<typename CLASS_POINT , typename CLASS_PLANE > | |
SIMD_FORCE_INLINE void | PLANE_CLIP_SEGMENT (const CLASS_POINT &s1, const CLASS_POINT &s2, const CLASS_PLANE &plane, CLASS_POINT &clipped) |
template<typename CLASS_POINT , typename CLASS_PLANE > | |
SIMD_FORCE_INLINE eLINE_PLANE_INTERSECTION_TYPE | PLANE_CLIP_SEGMENT2 (const CLASS_POINT &s1, const CLASS_POINT &s2, const CLASS_PLANE &plane, CLASS_POINT &clipped) |
Confirms if the plane intersect the edge or nor. | |
template<typename CLASS_POINT , typename CLASS_PLANE > | |
SIMD_FORCE_INLINE eLINE_PLANE_INTERSECTION_TYPE | PLANE_CLIP_SEGMENT_CLOSEST (const CLASS_POINT &s1, const CLASS_POINT &s2, const CLASS_PLANE &plane, CLASS_POINT &clipped1, CLASS_POINT &clipped2) |
Confirms if the plane intersect the edge or not. | |
template<typename T , typename CLASS_POINT , typename CLASS_PLANE > | |
SIMD_FORCE_INLINE bool | RAY_PLANE_COLLISION (const CLASS_PLANE &plane, const CLASS_POINT &vDir, const CLASS_POINT &vPoint, CLASS_POINT &pout, T &tparam) |
Ray plane collision in one way. | |
template<typename T , typename CLASS_POINT , typename CLASS_PLANE > | |
SIMD_FORCE_INLINE GUINT | LINE_PLANE_COLLISION (const CLASS_PLANE &plane, const CLASS_POINT &vDir, const CLASS_POINT &vPoint, CLASS_POINT &pout, T &tparam, T tmin, T tmax) |
line collision | |
template<typename CLASS_POINT , typename CLASS_PLANE > | |
SIMD_FORCE_INLINE bool | INTERSECT_PLANES (const CLASS_PLANE &p1, const CLASS_PLANE &p2, CLASS_POINT &p, CLASS_POINT &d) |
Returns the Ray on which 2 planes intersect if they do. Written by Rodrigo Hernandez on ODE convex collision. | |
template<typename CLASS_POINT > | |
SIMD_FORCE_INLINE void | CLOSEST_POINT_ON_SEGMENT (CLASS_POINT &cp, const CLASS_POINT &v, const CLASS_POINT &e1, const CLASS_POINT &e2) |
template<typename T , typename CLASS_POINT > | |
SIMD_FORCE_INLINE bool | LINE_INTERSECTION_PARAMS (const CLASS_POINT &dir1, CLASS_POINT &point1, const CLASS_POINT &dir2, CLASS_POINT &point2, T &t1, T &t2) |
Finds the line params where these lines intersect. | |
template<typename CLASS_POINT > | |
SIMD_FORCE_INLINE void | SEGMENT_COLLISION (const CLASS_POINT &vA1, const CLASS_POINT &vA2, const CLASS_POINT &vB1, const CLASS_POINT &vB2, CLASS_POINT &vPointA, CLASS_POINT &vPointB) |
Find closest points on segments. | |
template<typename T > | |
SIMD_FORCE_INLINE bool | BOX_AXIS_INTERSECT (T pos, T dir, T bmin, T bmax, T &tfirst, T &tlast) |
Line box intersection in one dimension. | |
template<typename T > | |
SIMD_FORCE_INLINE void | SORT_3_INDICES (const T *values, GUINT *order_indices) |
Sorts 3 componets. |
Definition in file gim_basic_geometry_operations.h.
Definition at line 86 of file gim_basic_geometry_operations.h.
Referenced by GIM_TRIANGLE::is_point_inside(), LINE_PLANE_COLLISION(), DISTANCE_PLANE_3D_FUNC::operator()(), PLANE_CLIP_SEGMENT(), PLANE_CLIP_SEGMENT2(), POINT_IN_HULL(), RAY_PLANE_COLLISION(), and GIM_TRIANGLE_CALCULATION_CACHE::triangle_collision().
#define EDGE_PLANE | ( | e1, | |
e2, | |||
n, | |||
plane | |||
) |
{\ vec3f _dif; \ VEC_DIFF(_dif,e2,e1); \ VEC_CROSS(plane,_dif,n); \ VEC_NORMALIZE(plane); \ plane[3] = VEC_DOT(e1,plane);\ }\
Calc a plane from an edge an a normal. plane is a vec4f.
Definition at line 78 of file gim_basic_geometry_operations.h.
Referenced by GIM_TRIANGLE_CALCULATION_CACHE::clip_triangle(), and GIM_TRIANGLE::get_edge_plane().
#define PARALELENORMALS 0.000001f |
Definition at line 46 of file gim_basic_geometry_operations.h.
#define PLANE_MINOR_AXES | ( | plane, | |
i0, | |||
i1 | |||
) | VEC_MINOR_AXES(plane, i0, i1) |
Finds the 2 smallest cartesian coordinates of a plane normal.
Definition at line 232 of file gim_basic_geometry_operations.h.
#define PLANEDIREPSILON 0.0000001f |
Definition at line 45 of file gim_basic_geometry_operations.h.
Referenced by LINE_PLANE_COLLISION(), and RAY_PLANE_COLLISION().
#define PROJECT_POINT_PLANE | ( | point, | |
plane, | |||
projected | |||
) |
{\ GREAL _dis;\ _dis = DISTANCE_PLANE_POINT(plane,point);\ VEC_SCALE(projected,-_dis,plane);\ VEC_SUM(projected,projected,point); \ }\
Definition at line 88 of file gim_basic_geometry_operations.h.
#define TRIANGLE_NORMAL | ( | v1, | |
v2, | |||
v3, | |||
n | |||
) |
{\ vec3f _dif1,_dif2;\ VEC_DIFF(_dif1,v2,v1);\ VEC_DIFF(_dif2,v3,v1);\ VEC_CROSS(n,_dif1,_dif2);\ VEC_NORMALIZE(n);\ }\
Definition at line 49 of file gim_basic_geometry_operations.h.
Referenced by GIM_TRIANGLE::get_normal().
#define TRIANGLE_NORMAL_FAST | ( | v1, | |
v2, | |||
v3, | |||
n | |||
) |
#define TRIANGLE_PLANE | ( | v1, | |
v2, | |||
v3, | |||
plane | |||
) |
{\ TRIANGLE_NORMAL(v1,v2,v3,plane);\ plane[3] = VEC_DOT(v1,plane);\ }\
plane is a vec4f
Definition at line 66 of file gim_basic_geometry_operations.h.
Referenced by GIM_TRIANGLE::get_plane(), and GIM_TRIANGLE_CALCULATION_CACHE::triangle_collision().
#define TRIANGLE_PLANE_FAST | ( | v1, | |
v2, | |||
v3, | |||
plane | |||
) |
{\ TRIANGLE_NORMAL_FAST(v1,v2,v3,plane);\ plane[3] = VEC_DOT(v1,plane);\ }\
plane is a vec4f
Definition at line 72 of file gim_basic_geometry_operations.h.
G_FRONT_PLANE_S1 | |
G_FRONT_PLANE_S2 | |
G_BACK_PLANE_S1 | |
G_BACK_PLANE_S2 | |
G_COLLIDE_PLANE_S1 | |
G_COLLIDE_PLANE_S2 |
Definition at line 129 of file gim_basic_geometry_operations.h.
Definition at line 122 of file gim_basic_geometry_operations.h.
SIMD_FORCE_INLINE bool BOX_AXIS_INTERSECT | ( | T | pos, |
T | dir, | ||
T | bmin, | ||
T | bmax, | ||
T & | tfirst, | ||
T & | tlast | ||
) |
Line box intersection in one dimension.
pos | Position of the ray |
dir | Projection of the Direction of the ray |
bmin | Minimum bound of the box |
bmax | Maximum bound of the box |
tfirst | the minimum projection. Assign to 0 at first. |
tlast | the maximum projection. Assign to INFINITY at first. |
Definition at line 498 of file gim_basic_geometry_operations.h.
References GIM_IS_ZERO, GIM_MAX, GIM_MIN, GIM_SWAP_NUMBERS, and GREAL.
SIMD_FORCE_INLINE void CLOSEST_POINT_ON_SEGMENT | ( | CLASS_POINT & | cp, |
const CLASS_POINT & | v, | ||
const CLASS_POINT & | e1, | ||
const CLASS_POINT & | e2 | ||
) |
Finds the closest point(cp) to (v) on a segment (e1,e2)
Definition at line 338 of file gim_basic_geometry_operations.h.
References GREAL, VEC_COPY, VEC_DIFF, VEC_DOT, VEC_SCALE, and VEC_SUM.
Referenced by SEGMENT_COLLISION().
SIMD_FORCE_INLINE bool INTERSECT_PLANES | ( | const CLASS_PLANE & | p1, |
const CLASS_PLANE & | p2, | ||
CLASS_POINT & | p, | ||
CLASS_POINT & | d | ||
) |
Returns the Ray on which 2 planes intersect if they do. Written by Rodrigo Hernandez on ODE convex collision.
p1 | Plane 1 |
p2 | Plane 2 |
p | Contains the origin of the ray upon returning if planes intersect |
d | Contains the direction of the ray upon returning if planes intersect |
Definition at line 313 of file gim_basic_geometry_operations.h.
References GIM_IS_ZERO, GREAL, VEC_CROSS, and VEC_DOT.
SIMD_FORCE_INLINE bool LINE_INTERSECTION_PARAMS | ( | const CLASS_POINT & | dir1, |
CLASS_POINT & | point1, | ||
const CLASS_POINT & | dir2, | ||
CLASS_POINT & | point2, | ||
T & | t1, | ||
T & | t2 | ||
) |
Finds the line params where these lines intersect.
dir1 | Direction of line 1 |
point1 | Point of line 1 |
dir2 | Direction of line 2 |
point2 | Point of line 2 |
t1 | Result Parameter for line 1 |
t2 | Result Parameter for line 2 |
dointersect | 0 if the lines won't intersect, else 1 |
Definition at line 375 of file gim_basic_geometry_operations.h.
References GIM_IS_ZERO, GREAL, VEC_DIFF, and VEC_DOT.
SIMD_FORCE_INLINE GUINT LINE_PLANE_COLLISION | ( | const CLASS_PLANE & | plane, |
const CLASS_POINT & | vDir, | ||
const CLASS_POINT & | vPoint, | ||
CLASS_POINT & | pout, | ||
T & | tparam, | ||
T | tmin, | ||
T | tmax | ||
) |
line collision
Definition at line 267 of file gim_basic_geometry_operations.h.
References btFabs(), DISTANCE_PLANE_POINT, GREAL, PLANEDIREPSILON, VEC_DOT, VEC_SCALE, and VEC_SUM.
Referenced by GIM_TRIANGLE::ray_collision(), GIM_TRIANGLE::ray_collision_front_side(), and SEGMENT_COLLISION().
SIMD_FORCE_INLINE void PLANE_CLIP_SEGMENT | ( | const CLASS_POINT & | s1, |
const CLASS_POINT & | s2, | ||
const CLASS_PLANE & | plane, | ||
CLASS_POINT & | clipped | ||
) |
Definition at line 110 of file gim_basic_geometry_operations.h.
References DISTANCE_PLANE_POINT, GREAL, VEC_DIFF, VEC_DOT, VEC_SCALE, and VEC_SUM.
SIMD_FORCE_INLINE eLINE_PLANE_INTERSECTION_TYPE PLANE_CLIP_SEGMENT2 | ( | const CLASS_POINT & | s1, |
const CLASS_POINT & | s2, | ||
const CLASS_PLANE & | plane, | ||
CLASS_POINT & | clipped | ||
) |
Confirms if the plane intersect the edge or nor.
intersection type must have the following values
Definition at line 153 of file gim_basic_geometry_operations.h.
References DISTANCE_PLANE_POINT, G_BACK_PLANE_S1, G_BACK_PLANE_S2, G_COLLIDE_PLANE_S1, G_COLLIDE_PLANE_S2, G_EPSILON, G_FRONT_PLANE_S1, G_FRONT_PLANE_S2, GREAL, VEC_DIFF, VEC_DOT, VEC_SCALE, and VEC_SUM.
Referenced by PLANE_CLIP_SEGMENT_CLOSEST().
SIMD_FORCE_INLINE eLINE_PLANE_INTERSECTION_TYPE PLANE_CLIP_SEGMENT_CLOSEST | ( | const CLASS_POINT & | s1, |
const CLASS_POINT & | s2, | ||
const CLASS_PLANE & | plane, | ||
CLASS_POINT & | clipped1, | ||
CLASS_POINT & | clipped2 | ||
) |
Confirms if the plane intersect the edge or not.
clipped1 and clipped2 are the vertices behind the plane. clipped1 is the closest
intersection_type must have the following values
Definition at line 195 of file gim_basic_geometry_operations.h.
References G_BACK_PLANE_S1, G_BACK_PLANE_S2, G_COLLIDE_PLANE_S1, G_COLLIDE_PLANE_S2, G_FRONT_PLANE_S1, G_FRONT_PLANE_S2, PLANE_CLIP_SEGMENT2(), and VEC_COPY.
SIMD_FORCE_INLINE bool POINT_IN_HULL | ( | const CLASS_POINT & | point, |
const CLASS_PLANE * | planes, | ||
GUINT | plane_count | ||
) |
Verifies if a point is in the plane hull.
Definition at line 97 of file gim_basic_geometry_operations.h.
References DISTANCE_PLANE_POINT, GREAL, and GUINT.
SIMD_FORCE_INLINE bool RAY_PLANE_COLLISION | ( | const CLASS_PLANE & | plane, |
const CLASS_POINT & | vDir, | ||
const CLASS_POINT & | vPoint, | ||
CLASS_POINT & | pout, | ||
T & | tparam | ||
) |
Ray plane collision in one way.
Intersects plane in one way only. The ray must face the plane (normals must be in opossite directions).
It uses the PLANEDIREPSILON constant.
Definition at line 240 of file gim_basic_geometry_operations.h.
References DISTANCE_PLANE_POINT, GREAL, PLANEDIREPSILON, VEC_DOT, VEC_SCALE, and VEC_SUM.
SIMD_FORCE_INLINE void SEGMENT_COLLISION | ( | const CLASS_POINT & | vA1, |
const CLASS_POINT & | vA2, | ||
const CLASS_POINT & | vB1, | ||
const CLASS_POINT & | vB2, | ||
CLASS_POINT & | vPointA, | ||
CLASS_POINT & | vPointB | ||
) |
Find closest points on segments.
Definition at line 399 of file gim_basic_geometry_operations.h.
References CLOSEST_POINT_ON_SEGMENT(), G_EPSILON, GIM_CLAMP, GIM_SWAP_NUMBERS, GREAL, LINE_PLANE_COLLISION(), VEC_CROSS, VEC_DIFF, VEC_DOT, VEC_SCALE, and VEC_SUM.
Referenced by GIM_TRIANGLE_CALCULATION_CACHE::cross_line_intersection_test().
SIMD_FORCE_INLINE void SORT_3_INDICES | ( | const T * | values, |
GUINT * | order_indices | ||
) |
Sorts 3 componets.
Definition at line 516 of file gim_basic_geometry_operations.h.
References GUINT.