CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csIntersect3 Class Reference
[Geometry utilities]

Some functions to perform various intersection calculations with 3D line segments. More...

#include <math3d.h>

List of all members.

Static Public Methods

bool IntersectPolygon (const csPlane3 &plane, csPoly3D *poly, csSegment3 &segment)
 Intersect a plane with a 3D polygon and return the line segment corresponding with this intersection.

int IntersectSegment (csPlane3 *planes, int num_planes, csSegment3 &seg)
 Intersect a segment with a frustum (given as a set of planes).

bool IntersectTriangle (const csVector3 &tr1, const csVector3 &tr2, const csVector3 &tr3, const csSegment3 &seg, csVector3 &isect)
 Intersect a 3D segment with a triangle.

bool Planes (const csVector3 &u, const csVector3 &v, const csPlane3 *planes, int length, csVector3 &isect, float &dist)
 If a number of planes enclose a convex space (with their normals pointing outwards).

bool Plane (const csVector3 &u, const csVector3 &v, const csVector3 &normal, const csVector3 &a, csVector3 &isect, float &dist)
 Intersect a 3D segment with a plane.

bool Plane (const csVector3 &u, const csVector3 &v, const csPlane3 &p, csVector3 &isect, float &dist)
 Intersect a 3D segment with a plane.

bool Planes (const csPlane3 &p1, const csPlane3 &p2, const csPlane3 &p3, csVector3 &isect)
 Intersect 3 planes to get the point that is part of all three planes.

bool PlaneXPlane (const csPlane3 &p1, float x2, csPlane2 &isect)
 Intersect a regular plane and an axis aligned plane and return the intersection (line) as a 2D plane.

bool PlaneYPlane (const csPlane3 &p1, float y2, csPlane2 &isect)
 Intersect a regular plane and an axis aligned plane and return the intersection (line) as a 2D plane.

bool PlaneZPlane (const csPlane3 &p1, float z2, csPlane2 &isect)
 Intersect a regular plane and an axis aligned plane and return the intersection (line) as a 2D plane.

bool PlaneAxisPlane (const csPlane3 &p1, int nr, float pos, csPlane2 &isect)
 Intersect a regular plane and an axis aligned plane and return the intersection (line) as a 2D plane.

float Z0Plane (const csVector3 &v1, const csVector3 &v2, csVector3 &isect)
 Intersect a 3D segment with the z = 0 plane.

float Z0Plane (const csSegment3 &uv, csVector3 &isect)
 Intersect a 3D segment with the z = 0 plane.

float ZPlane (float zval, const csVector3 &u, const csVector3 &v, csVector3 &isect)
 Intersect a 3D segment with the plane z = zval.

float ZPlane (float zval, const csSegment3 &uv, csVector3 &isect)
 Intersect a 3D segment with the plane z = zval.

float XFrustum (float A, const csVector3 &u, const csVector3 &v, csVector3 &isect)
 Intersect a 3D segment with the frustum plane Ax + z = 0.

float XFrustum (float A, const csSegment3 &uv, csVector3 &isect)
 Intersect a 3D segment with the frustum plane Ax + z = 0.

float YFrustum (float B, const csVector3 &u, const csVector3 &v, csVector3 &isect)
 Intersect a 3D segment with the frustum plane By + z = 0.

float YFrustum (float B, const csSegment3 &uv, csVector3 &isect)
 Intersect a 3D segment with the frustum plane By + z = 0.

int BoxSegment (const csBox3 &box, const csSegment3 &segment, csVector3 &isect, float *pr=0)
 Intersect a segment with a box and returns one of CS_BOX_SIDE_...

bool BoxFrustum (const csBox3 &box, csPlane3 *frustum, uint32 inClipMask, uint32 &outClipMask)
 Intersect an AABB with a frustum.

bool BoxSphere (const csBox3 &box, const csVector3 &center, float sqradius)
 Test if a box intersects with a sphere.


Detailed Description

Some functions to perform various intersection calculations with 3D line segments.

This is a static class and contains only static member functions.

Definition at line 273 of file math3d.h.


Member Function Documentation

bool csIntersect3::BoxFrustum (  const csBox3 &    box,
csPlane3 *    frustum,
uint32    inClipMask,
uint32 &    outClipMask
)  [static]
 

Intersect an AABB with a frustum.

The frustum may contain up to 32 planes. Active planes are defined using the 'inClipMask'. It will return true if AABB is visible in frustum. If the AABB intersects with the frustum then 'outClipMask' will contain the mask for all planes intersecting with the AABB. This can be used as 'inClipMask' for subsequent frustum tests with children of the AABB (i.e. other AABB inside this AABB).

int csIntersect3::BoxSegment (  const csBox3 &    box,
const csSegment3 &    segment,
csVector3 &    isect,
float *    pr = 0
)  [static]
 

Intersect a segment with a box and returns one of CS_BOX_SIDE_...

if it intersects, CS_BOX_INSIDE if inside, or -1 otherwise. The intersection point is also returned. If 'pr' is given then a number between 0 and 1 is returned which corresponds to the position on the segment. If we were in the box this this function will return CS_BOX_INSIDE. In this case 'isect' will be set to the start of the segment and *pr to 0.

bool csIntersect3::BoxSphere (  const csBox3 &    box,
const csVector3 &    center,
float    sqradius
)  [static]
 

Test if a box intersects with a sphere.

The intersection is not computed. The sphere is given with squared radius.

bool csIntersect3::IntersectPolygon (  const csPlane3 &    plane,
csPoly3D *    poly,
csSegment3 &    segment
)  [static]
 

Intersect a plane with a 3D polygon and return the line segment corresponding with this intersection.

Returns true if there is an intersection. If false then 'segment' will not be valid.

int csIntersect3::IntersectSegment (  csPlane3 *    planes,
int    num_planes,
csSegment3 &    seg
)  [static]
 

Intersect a segment with a frustum (given as a set of planes).

Returns the clipped segment (i.e. the part of the segment that is visible in the frustum). Returns -1 if the segment is entirely outside the frustum. Returns 0 if the segment is not modified and returns 1 otherwise. The input segment will be modified. @@ WARNING! This function may not work completely ok. It has only barely been tested and is now unused.

bool csIntersect3::IntersectTriangle (  const csVector3 &    tr1,
const csVector3 &    tr2,
const csVector3 &    tr3,
const csSegment3 &    seg,
csVector3 &    isect
)  [static]
 

Intersect a 3D segment with a triangle.

Returns true if there is an intersection. In that case the intersection point will be in 'isect'.

bool csIntersect3::Plane (  const csVector3 &    u,
const csVector3 &    v,
const csPlane3 &    p,
csVector3 &    isect,
float &    dist
)  [static]
 

Intersect a 3D segment with a plane.

Returns true if there is an intersection, with the intersection point returned in isect. The distance from u to the intersection point is returned in dist. The distance that is returned is a normalized distance with respect to the given input vector. i.e. a distance of 0.5 means that the intersection point is halfway u and v. There are two cases in which this method will return false:

  • If the plane and the segment are parallel, then 'dist' will be set equal to 0, and 'isect' equal to 'v'.
  • If the segment does not cross the plane (i.e. if 'dist'>1+epsilon or 'dist'<-epsilon, where epsilon is a very small value near to zero) then 'isect's value is (0, 0, 0).
Remarks:
'p' is the plane, expressed as: A x + B y + C z + D = 0 , where (A,B,C) is the normal vector of the plane. 'u' and 'v' are the start (U point) and the end (V point) of the segment. 'isect' is searched along the segment U + x (V - U); the unknown 'x' value is got by: x = [(A,B,C) * U + D ] / (A,B,C) * (U - V), where * is the dot product.

bool csIntersect3::Plane (  const csVector3 &    u,
const csVector3 &    v,
const csVector3 &    normal,
const csVector3 &    a,
csVector3 &    isect,
float &    dist
)  [static]
 

Intersect a 3D segment with a plane.

Returns true if there is an intersection, with the intersection point returned in isect.

bool csIntersect3::PlaneAxisPlane (  const csPlane3 &    p1,
int    nr,
float    pos,
csPlane2 &    isect
)  [inline, static]
 

Intersect a regular plane and an axis aligned plane and return the intersection (line) as a 2D plane.

This intersection is defined on the axis aligned plane. Returns false if there is no intersection.

Definition at line 391 of file math3d.h.

bool csIntersect3::Planes (  const csPlane3 &    p1,
const csPlane3 &    p2,
const csPlane3 &    p3,
csVector3 &    isect
)  [static]
 

Intersect 3 planes to get the point that is part of all three planes.

Returns true, if there is a single point that fits. If some planes are parallel, then it will return false.

bool csIntersect3::Planes (  const csVector3 &    u,
const csVector3 &    v,
const csPlane3 *    planes,
int    length,
csVector3 &    isect,
float &    dist
)  [static]
 

If a number of planes enclose a convex space (with their normals pointing outwards).

This method returns true if they are intersected by a segment. isect contains the closest intersection point. dist contains the distance to that point (with distance between u and v being 1)

bool csIntersect3::PlaneXPlane (  const csPlane3 &    p1,
float    x2,
csPlane2 &    isect
)  [static]
 

Intersect a regular plane and an axis aligned plane and return the intersection (line) as a 2D plane.

This intersection is defined on the axis aligned plane. Returns false if there is no intersection.

bool csIntersect3::PlaneYPlane (  const csPlane3 &    p1,
float    y2,
csPlane2 &    isect
)  [static]
 

Intersect a regular plane and an axis aligned plane and return the intersection (line) as a 2D plane.

This intersection is defined on the axis aligned plane. Returns false if there is no intersection.

bool csIntersect3::PlaneZPlane (  const csPlane3 &    p1,
float    z2,
csPlane2 &    isect
)  [static]
 

Intersect a regular plane and an axis aligned plane and return the intersection (line) as a 2D plane.

This intersection is defined on the axis aligned plane. Returns false if there is no intersection.

float csIntersect3::XFrustum (  float    A,
const csSegment3 &    uv,
csVector3 &    isect
)  [inline, static]
 

Intersect a 3D segment with the frustum plane Ax + z = 0.

Assumes an intersection, and returns the intersection point in isect.

Definition at line 460 of file math3d.h.

References csSegment3::End(), and csSegment3::Start().

float csIntersect3::XFrustum (  float    A,
const csVector3 &    u,
const csVector3 &    v,
csVector3 &    isect
)  [static]
 

Intersect a 3D segment with the frustum plane Ax + z = 0.

Assumes an intersection, and returns the intersection point in isect.

float csIntersect3::YFrustum (  float    B,
const csSegment3 &    uv,
csVector3 &    isect
)  [inline, static]
 

Intersect a 3D segment with the frustum plane By + z = 0.

Assumes an intersection, and returns the intersection point in isect.

Definition at line 477 of file math3d.h.

References csSegment3::End(), and csSegment3::Start().

float csIntersect3::YFrustum (  float    B,
const csVector3 &    u,
const csVector3 &    v,
csVector3 &    isect
)  [static]
 

Intersect a 3D segment with the frustum plane By + z = 0.

Assumes an intersection, and returns the intersection point in isect.

float csIntersect3::Z0Plane (  const csSegment3 &    uv,
csVector3 &    isect
)  [inline, static]
 

Intersect a 3D segment with the z = 0 plane.

Assumes that there is an intersection (fails if the segment is parallel to the plane), and returns the distance from u to the intersection point. The intersection point is returned in isect.

Definition at line 419 of file math3d.h.

References csSegment3::End(), and csSegment3::Start().

float csIntersect3::Z0Plane (  const csVector3 &    v1,
const csVector3 &    v2,
csVector3 &    isect
)  [static]
 

Intersect a 3D segment with the z = 0 plane.

Assumes that there is an intersection (fails if the segment is parallel to the plane), and returns the distance from u to the intersection point. The intersection point is returned in isect.

float csIntersect3::ZPlane (  float    zval,
const csSegment3 &    uv,
csVector3 &    isect
)  [inline, static]
 

Intersect a 3D segment with the plane z = zval.

Assumes that there is an intersection (fails if the segment is parallel to the plane), and returns the distance from u to the intersection point. The intersection point is returned in isect.

Definition at line 442 of file math3d.h.

References csSegment3::End(), and csSegment3::Start().

float csIntersect3::ZPlane (  float    zval,
const csVector3 &    u,
const csVector3 &    v,
csVector3 &    isect
)  [static]
 

Intersect a 3D segment with the plane z = zval.

Assumes that there is an intersection (fails if the segment is parallel to the plane), and returns the distance from u to the intersection point. The intersection point is returned in isect.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.2.18