CrystalSpace

Public API Reference

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

csMath2 Class Reference
[Geometry utilities]

Various functions in 2D, such as 2D vector functions. More...

#include <csgeom/math2d.h>

List of all members.

Static Public Member Functions

int WhichSide2D (const csVector2 &v, const csVector2 &s1, const csVector2 &s2)
 Calculates which side of a line a given point is on.
int WhichSide2D (const csVector2 &v, const csSegment2 &s)
 Calculates which side of a line a given point is on.
int InPoly2D (const csVector2 &v, csVector2 *P, int n, csBox2 *bounding_box)
 Calculates whether a vector lies inside a given 2D polygon.
float Area2 (const csVector2 &a, const csVector2 &b, const csVector2 &c)
 Calculates 2 x the area of a given triangle.
float Right (const csVector2 &a, const csVector2 &b, const csVector2 &c)
 Calculates whether a point lies to the right of a given line.
float Left (const csVector2 &a, const csVector2 &b, const csVector2 &c)
 Calculates whether a point lies to the left of a given line.
bool Visible (const csVector2 &p, const csPlane2 &pl)
 Check if the plane is visible from the given point.
bool PlanesEqual (const csPlane2 &p1, const csPlane2 &p2)
 Check if two planes are almost equal.
bool PlanesClose (const csPlane2 &p1, const csPlane2 &p2)
 Check if two planes are close together.


Detailed Description

Various functions in 2D, such as 2D vector functions.

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

Definition at line 50 of file math2d.h.


Member Function Documentation

float csMath2::Area2 const csVector2 a,
const csVector2 b,
const csVector2 c
[inline, static]
 

Calculates 2 x the area of a given triangle.

Returns twice the signed area of the triangle determined by a,b,c, positive if a,b,c are oriented ccw, and negative if cw.

Definition at line 96 of file math2d.h.

References csVector2::x, and csVector2::y.

Referenced by Left(), and Right().

int csMath2::InPoly2D const csVector2 v,
csVector2 P,
int  n,
csBox2 bounding_box
[static]
 

Calculates whether a vector lies inside a given 2D polygon.

Return CS_POLY_IN, CS_POLY_OUT, or CS_POLY_ON for this vector with respect to the given polygon. The polygon is given as an array of 2D vectors with a bounding box. WARNING: does no safety checking for P or bounding_box.

float csMath2::Left const csVector2 a,
const csVector2 b,
const csVector2 c
[inline, static]
 

Calculates whether a point lies to the left of a given line.

Returns true iff c is strictly to the left of the directed line through a to b.

Definition at line 123 of file math2d.h.

References Area2().

bool csMath2::PlanesClose const csPlane2 p1,
const csPlane2 p2
[static]
 

Check if two planes are close together.

Two planes are close if there are almost equal OR if the normalized versions are almost equal.

bool csMath2::PlanesEqual const csPlane2 p1,
const csPlane2 p2
[inline, static]
 

Check if two planes are almost equal.

The function returns true iff each component of the plane equation for one plane is within .001 of the corresponding component of the other plane.

Definition at line 144 of file math2d.h.

References csPlane2::CC, and csPlane2::norm.

float csMath2::Right const csVector2 a,
const csVector2 b,
const csVector2 c
[inline, static]
 

Calculates whether a point lies to the right of a given line.

Returns true iff c is strictly to the right of the directed line through a to b.

Definition at line 111 of file math2d.h.

References Area2().

bool csMath2::Visible const csVector2 p,
const csPlane2 pl
[inline, static]
 

Check if the plane is visible from the given point.

This function does a back-face culling test to see whether the front face of plane pl is visible from point p.

Definition at line 135 of file math2d.h.

References csPlane2::Classify().

int csMath2::WhichSide2D const csVector2 v,
const csSegment2 s
[inline, static]
 

Calculates which side of a line a given point is on.

Returns -1 if point v is left of line segment 'seg' 1 if point v is right of segment 'seg' or 0 if point v lies on segment 'seg'.

Definition at line 75 of file math2d.h.

References csSegment2::End(), csSegment2::Start(), and WhichSide2D().

int csMath2::WhichSide2D const csVector2 v,
const csVector2 s1,
const csVector2 s2
[inline, static]
 

Calculates which side of a line a given point is on.

Returns -1 if point v is left of line segment 's1-s2', 1 if point v is right of segment 's1-s2' or 0 if point v lies on segment 's1-s2'.

Definition at line 59 of file math2d.h.

References csVector2::x, and csVector2::y.

Referenced by WhichSide2D().


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