CrystalSpace

Public API Reference

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

csVector2 Class Reference
[Geometry utilities]

A 2D vector. More...

#include <csgeom/vector2.h>

List of all members.

Public Member Functions

 csVector2 ()
 Make a new vector. No initialization is done.
 csVector2 (float x, float y)
 Make a new vector and initialize with the given values.
csString Description () const
 Return a textual representation of the vector in the form "x,y".
void Set (float ix, float iy)
 Set vector to given values.
void Set (csVector2 const &v)
 Set vector to given values.
void Set (float const *v)
 Set the value of this vector.
void Set (float v)
 Set the value of this vector so that all components are the same.
void Get (float *v)
 Get the value of this vector.
float Norm () const
 Return the norm (magnitude) of this vector.
float SquaredNorm () const
 Return the squared norm (magnitude) of this vector.
void Rotate (float angle)
 Rotate vector around the origin by a given angle in radians.
float IsLeft (const csVector2 &p0, const csVector2 &p1)
 Test if this point is left of the line through p0 and p1.
csVector2operator+= (const csVector2 &v)
 Add another vector to this vector.
csVector2operator-= (const csVector2 &v)
 Subtract another vector from this vector.
csVector2operator *= (float f)
 Multiply this vector by a scalar.
csVector2operator/= (float f)
 Divide this vector by a scalar.
csVector2 operator+ () const
 Unary + operator.
csVector2 operator- () const
 Unary - operator.

Static Public Member Functions

float Norm (csVector2 const &v)
 Return the norm (magnitude) of a 2D vector.

Public Attributes

float x
 X component of vector.
float y
 Y component of vector.

Friends

csVector2 operator+ (const csVector2 &v1, const csVector2 &v2)
 Add two vectors.
csVector2 operator- (const csVector2 &v1, const csVector2 &v2)
 Subtract two vectors.
float operator * (const csVector2 &v1, const csVector2 &v2)
 Take the dot product of two vectors.
csVector2 operator * (const csVector2 &v, float f)
 Multiply a vector and a scalar.
csVector2 operator * (float f, const csVector2 &v)
 Multiply a vector and a scalar.
csVector2 operator/ (const csVector2 &v, float f)
 Divide a vector by a scalar.
bool operator== (const csVector2 &v1, const csVector2 &v2)
 Check if two vectors are equal.
bool operator!= (const csVector2 &v1, const csVector2 &v2)
 Check if two vectors are not equal.
bool operator< (const csVector2 &v, float f)
 Test if each component of a vector is less than a small epsilon value.
bool operator> (float f, const csVector2 &v)
 Test if each component of a vector is greater than a small epsilon value.


Detailed Description

A 2D vector.

Definition at line 35 of file vector2.h.


Constructor & Destructor Documentation

csVector2::csVector2  )  [inline]
 

Make a new vector. No initialization is done.

Definition at line 44 of file vector2.h.

Referenced by operator-().

csVector2::csVector2 float  x,
float  y
[inline]
 

Make a new vector and initialize with the given values.

Definition at line 47 of file vector2.h.

References x, and y.


Member Function Documentation

csString csVector2::Description  )  const
 

Return a textual representation of the vector in the form "x,y".

void csVector2::Get float *  v  )  [inline]
 

Get the value of this vector.

Definition at line 67 of file vector2.h.

float csVector2::IsLeft const csVector2 p0,
const csVector2 p1
[inline]
 

Test if this point is left of the line through p0 and p1.

Returns:
>0 if this point is left, 0 if on the line and <0 if right.

Definition at line 86 of file vector2.h.

References x, and y.

float csVector2::Norm  )  const
 

Return the norm (magnitude) of this vector.

float csVector2::Norm csVector2 const &  v  )  [static]
 

Return the norm (magnitude) of a 2D vector.

Referenced by csPlane2::Normalize().

csVector2& csVector2::operator *= float  f  )  [inline]
 

Multiply this vector by a scalar.

Definition at line 100 of file vector2.h.

References x, and y.

csVector2 csVector2::operator+  )  const [inline]
 

Unary + operator.

Definition at line 112 of file vector2.h.

csVector2& csVector2::operator+= const csVector2 v  )  [inline]
 

Add another vector to this vector.

Definition at line 92 of file vector2.h.

References x, and y.

csVector2 csVector2::operator-  )  const [inline]
 

Unary - operator.

Definition at line 115 of file vector2.h.

References csVector2(), x, and y.

csVector2& csVector2::operator-= const csVector2 v  )  [inline]
 

Subtract another vector from this vector.

Definition at line 96 of file vector2.h.

References x, and y.

csVector2& csVector2::operator/= float  f  )  [inline]
 

Divide this vector by a scalar.

Definition at line 103 of file vector2.h.

References x, and y.

void csVector2::Rotate float  angle  ) 
 

Rotate vector around the origin by a given angle in radians.

void csVector2::Set float  v  )  [inline]
 

Set the value of this vector so that all components are the same.

Definition at line 64 of file vector2.h.

References x, and y.

void csVector2::Set float const *  v  )  [inline]
 

Set the value of this vector.

Definition at line 61 of file vector2.h.

References x, and y.

void csVector2::Set csVector2 const &  v  )  [inline]
 

Set vector to given values.

Definition at line 57 of file vector2.h.

References x, and y.

void csVector2::Set float  ix,
float  iy
[inline]
 

Set vector to given values.

Definition at line 53 of file vector2.h.

References x, and y.

Referenced by csShaderVariable::GetValue(), and csShaderVariable::SetValue().

float csVector2::SquaredNorm  )  const [inline]
 

Return the squared norm (magnitude) of this vector.

Definition at line 76 of file vector2.h.

References x, and y.

Referenced by csPlane2::SquaredDistance().


Friends And Related Function Documentation

csVector2 operator * float  f,
const csVector2 v
[friend]
 

Multiply a vector and a scalar.

csVector2 operator * const csVector2 v,
float  f
[friend]
 

Multiply a vector and a scalar.

float operator * const csVector2 v1,
const csVector2 v2
[friend]
 

Take the dot product of two vectors.

bool operator!= const csVector2 v1,
const csVector2 v2
[friend]
 

Check if two vectors are not equal.

csVector2 operator+ const csVector2 v1,
const csVector2 v2
[friend]
 

Add two vectors.

csVector2 operator- const csVector2 v1,
const csVector2 v2
[friend]
 

Subtract two vectors.

csVector2 operator/ const csVector2 v,
float  f
[friend]
 

Divide a vector by a scalar.

bool operator< const csVector2 v,
float  f
[friend]
 

Test if each component of a vector is less than a small epsilon value.

Definition at line 140 of file vector2.h.

bool operator== const csVector2 v1,
const csVector2 v2
[friend]
 

Check if two vectors are equal.

bool operator> float  f,
const csVector2 v
[friend]
 

Test if each component of a vector is greater than a small epsilon value.

Definition at line 144 of file vector2.h.


Member Data Documentation

float csVector2::x
 

X component of vector.

Definition at line 39 of file vector2.h.

Referenced by csPlane2::A(), csBox2::AddBoundingVertex(), csBox2::AddBoundingVertexSmart(), csBox2::AddBoundingVertexSmartTest(), csBox2::AddBoundingVertexTest(), csPoly2D::AddVertex(), csMath2::Area2(), csPlane2::Classify(), csBox2::Contains(), csVector2(), csBox2::Empty(), csBox2::In(), csBox2::Intersect(), csBoxClipper::IsInside(), IsLeft(), csBox2::Max(), csBox2::MaxX(), csBox2::Min(), csBox2::MinX(), operator *=(), operator+=(), operator-(), operator-=(), operator/=(), csBox2::Overlap(), csIntersect2::SegmentPlaneNoTest(), Set(), csPlane2::Set(), csBox2::Set(), csBox2::SetMax(), csBox2::SetMin(), csShaderVariable::SetValue(), SquaredNorm(), csBox2::StartBoundingBox(), and csMath2::WhichSide2D().

float csVector2::y
 

Y component of vector.

Definition at line 41 of file vector2.h.

Referenced by csBox2::AddBoundingVertex(), csBox2::AddBoundingVertexSmart(), csBox2::AddBoundingVertexSmartTest(), csBox2::AddBoundingVertexTest(), csPoly2D::AddVertex(), csMath2::Area2(), csPlane2::B(), csPlane2::Classify(), csBox2::Contains(), csVector2(), csBox2::Empty(), csBox2::In(), csBox2::Intersect(), csBoxClipper::IsInside(), IsLeft(), csBox2::Max(), csBox2::MaxY(), csBox2::Min(), csBox2::MinY(), operator *=(), operator+=(), operator-(), operator-=(), operator/=(), csBox2::Overlap(), csIntersect2::SegmentPlaneNoTest(), Set(), csPlane2::Set(), csBox2::Set(), csBox2::SetMax(), csBox2::SetMin(), csShaderVariable::SetValue(), SquaredNorm(), csBox2::StartBoundingBox(), and csMath2::WhichSide2D().


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