Chipmunk++
 All Classes Functions Variables Pages
Public Member Functions | Static Public Member Functions | Public Attributes
cp::Vect Class Reference

2D Vector class More...

#include <vect.hpp>

List of all members.

Public Member Functions

 Vect (Float x, Float y)
 Constructor.
 Vect ()
 Creates the zero vector.
 Vect (const cpVect &)
 Copy constructor.
 operator cpVect () const
 Conversion operator to Chipmunk's cpVect.
Vectoperator/= (const Float v)
Vectoperator*= (const Float v)
Vectoperator-= (const Vect &rhs)
Vectoperator-= (const Float v)
Vectoperator+= (const Float v)
Vectoperator+= (const Vect &rhs)
Vectoperator++ ()
Vectoperator-- ()
Float length () const
 Returns the length.
Float lengthSq () const
 Returns the squared length. Faster than Vect::length() when you only need to compare lengths.
Vect perp () const
 Returns a perpendicular vector. (90 degree rotation)
Vect rperp () const
 Returns a perpendicular vector. (-90 degree rotation)
Vect normalize () const
 Returns a normalized copy.
Vect normalizeSafe () const
Vect clamp (Float len) const
 Clamp v to length len.
Float toAngle () const
 Returns the angular direction the vector is pointing in (in radians).
Vect rotate (Vect v) const
 Uses complex multiplication to return a copy rotated by v. Scaling will occur if the vector isn't a unit vector.
Vect unrotate (Vect v) const
 Inverse of Vect::rotate.

Static Public Member Functions

static Vect forAngle (Float a)
 Returns the unit length vector for the given angle (in radians).
static Float dot (Vect v1, Vect v2)
 Vector dot product.
static Float cross (Vect v1, Vect v2)
static Vect project (Vect v1, Vect v2)
 Returns the vector projection of v1 onto v2.
static Vect lerp (Vect v1, Vect v2, Float t)
 Linearly interpolate between a and b.
static Vect lerpconst (Vect v1, Vect v2, Float d)
 Linearly interpolate between v1 towards v2 by distance d.
static Vect slerp (Vect v1, Vect v2, Float t)
 Spherical linearly interpolate between v1 and v2.
static Vect slerpconst (Vect v1, Vect v2, Float a)
 Spherical linearly interpolate between v1 towards v2 by no more than angle a in radians.
static Float dist (Vect v1, Vect v2)
 Returns the distance between v1 and v2.
static Float distSq (Vect v1, Vect v2)
static bool near (Vect v1, Vect v2, Float dist)
 Returns true if the distance between v1 and v2 is less than dist.

Public Attributes

Float x
 x component
Float y
 y component

Detailed Description

2D Vector class


Member Function Documentation

Float cp::Vect::cross ( Vect  v1,
Vect  v2 
)
static

2D vector cross product analog. The cross product of 2D vectors results in a 3D vector with only a z component. This function returns the value along the z-axis.

Float cp::Vect::distSq ( Vect  v1,
Vect  v2 
)
static

Returns the squared distance between v1 and v2. Faster than Vect::dist when you only need to compare distances.

Vect cp::Vect::normalizeSafe ( ) const

Returns a normalized copy or the zero vector if the vector was already the zero vector. Protects against divide by zero errors.


The documentation for this class was generated from the following files: