Files Class List
Point2< TYPE > Class Template Reference

Detailed Description

template<typename TYPE>
class cy::Point2< TYPE >

2D point (vector) class

#include <cyPoint.h>

Public Member Functions

Constructors
 Point2 ()
 
 Point2 (const TYPE &_x, const TYPE &_y)
 
 Point2 (const Point2 &p)
 
 Point2 (const TYPE &v)
 
 Point2 (const Point3< TYPE > &p)
 
 Point2 (const Point4< TYPE > &p)
 
template<typename T >
 Point2 (const Point2< T > &p)
 
template<typename T >
 Point2 (const Point3< T > &p)
 
template<typename T >
 Point2 (const Point4< T > &p)
 
template<int M>
 Point2 (const Point< TYPE, M > &p)
 
template<typename T , int M>
 Point2 (const Point< T, M > &p)
 
template<typename P >
 Point2 (const P &p)
 
Set & Get value methods
void Zero ()
 
void Get (TYPE *p) const
 
void Set (const TYPE *p)
 
void Set (const TYPE &v)
 
void Set (const TYPE &_x, const TYPE &_y)
 
General methods
TYPE LengthSquared () const
 
TYPE Length () const
 
void Normalize ()
 
Point2 GetNormalized () const
 
TYPE Sum () const
 
bool IsZero () const
 
TYPE Min () const
 
TYPE Max () const
 
int MinID () const
 
int MaxID () const
 
Limit methods
void Clamp (const TYPE &minValue, const TYPE &maxValue)
 
void ClampMin (const TYPE &v)
 
void ClampMax (const TYPE &v)
 
void Abs ()
 
Unary operators
Point2 operator- () const
 
Binary operators
Point2 operator+ (const Point2 &p) const
 
Point2 operator- (const Point2 &p) const
 
Point2 operator* (const Point2 &p) const
 
Point2 operator/ (const Point2 &p) const
 
Point2 operator+ (const TYPE &v) const
 
Point2 operator- (const TYPE &v) const
 
Point2 operator* (const TYPE &v) const
 
Point2 operator/ (const TYPE &v) const
 
Assignment operators
const Point2operator= (const Point2 &p)
 
const Point2operator+= (const Point2 &p)
 
const Point2operator-= (const Point2 &p)
 
const Point2operator*= (const Point2 &p)
 
const Point2operator/= (const Point2 &p)
 
const Point2operator+= (const TYPE &v)
 
const Point2operator-= (const TYPE &v)
 
const Point2operator*= (const TYPE &v)
 
const Point2operator/= (const TYPE &v)
 
Test operators
bool operator== (const Point2 &p) const
 
bool operator!= (const Point2 &p) const
 
Access operators
TYPE & operator[] (int i)
 
const TYPE & operator[] (int i) const
 
TYPE & Element (int i)
 
const TYPE & Element (int i) const
 
TYPE * Data ()
 
const TYPE * Data () const
 
Cross product and dot product
TYPE Cross (const Point2 &p) const
 
TYPE operator^ (const Point2 &p) const
 
TYPE Dot (const Point2 &p) const
 
TYPE operator% (const Point2 &p) const
 

Public Attributes

Components of the point/vector
TYPE x
 
TYPE y
 

Friends

Point2 operator+ (const TYPE v, const Point2 &p)
 
Point2 operator- (const TYPE v, const Point2 &p)
 
Point2 operator* (const TYPE v, const Point2 &p)
 

Member Function Documentation

§ Zero()

void Zero ( )

Sets the coordinates as zero.

§ Get()

void Get ( TYPE *  p) const

Puts the coordinate values into the array.

§ Set() [1/3]

void Set ( const TYPE *  p)

Sets the coordinates using the values in the given array.

§ Set() [2/3]

void Set ( const TYPE &  v)

Sets all coordinates using the given value.

§ Set() [3/3]

void Set ( const TYPE &  _x,
const TYPE &  _y 
)

Sets the coordinates using the given values.

§ LengthSquared()

TYPE LengthSquared ( ) const

Returns the square of the length. Effectively, this is the dot product of the vector with itself.

§ Length()

TYPE Length ( ) const

Returns the length of the vector.

§ Normalize()

void Normalize ( )

Normalizes the vector, such that its length becomes 1.

§ GetNormalized()

Point2 GetNormalized ( ) const

Returns a normalized copy of the vector.

§ Sum()

TYPE Sum ( ) const

Returns the sum of its components.

§ IsZero()

bool IsZero ( ) const

Returns true if all components are exactly zero.

§ Min()

TYPE Min ( ) const

Returns the square of the length. Effectively, this is the dot product of the vector with itself.

§ Max()

TYPE Max ( ) const

Returns the square of the length. Effectively, this is the dot product of the vector with itself.

§ MinID()

int MinID ( ) const

Returns the square of the length. Effectively, this is the dot product of the vector with itself.

§ MaxID()

int MaxID ( ) const

Returns the square of the length. Effectively, this is the dot product of the vector with itself.

§ Clamp()

void Clamp ( const TYPE &  minValue,
const TYPE &  maxValue 
)

Converts all negative components to positive values.

§ ClampMin()

void ClampMin ( const TYPE &  v)

Converts all negative components to positive values.

§ ClampMax()

void ClampMax ( const TYPE &  v)

Converts all negative components to positive values.

§ Abs()

void Abs ( )

Converts all negative components to positive values.

§ Cross()

TYPE Cross ( const Point2< TYPE > &  p) const

Cross product.

§ operator^()

TYPE operator^ ( const Point2< TYPE > &  p) const

Cross product operator.

§ Dot()

TYPE Dot ( const Point2< TYPE > &  p) const

Dot product.

§ operator%()

TYPE operator% ( const Point2< TYPE > &  p) const

Dot product operator.

Friends And Related Function Documentation

§ operator+

Point2 operator+ ( const TYPE  v,
const Point2< TYPE > &  p 
)
friend

Addition with a constant.

§ operator-

Point2 operator- ( const TYPE  v,
const Point2< TYPE > &  p 
)
friend

Subtraction from a constant.

§ operator*

Point2 operator* ( const TYPE  v,
const Point2< TYPE > &  p 
)
friend

Multiplication with a constant.