Colobot
Public Member Functions | Public Attributes | Friends | List of all members
Math::Point Struct Reference

2D point More...

#include <point.h>

Public Member Functions

 Point ()
 Constructs a zero point: (0,0) More...
 
 Point (float _x, float _y)
 Constructs a point from given coords: (x,y) More...
 
void LoadZero ()
 Sets the zero point: (0,0) More...
 
float * Array ()
 Returns the struct cast to float* array; use with care! More...
 
const float * Array () const
 Returns the struct cast to const float* array; use with care! More...
 
float Length ()
 Returns the distance from (0,0) to the point (x,y) More...
 
Point operator- () const
 Returns the inverted point. More...
 
const Pointoperator+= (const Point &right)
 Adds the given point. More...
 
const Pointoperator-= (const Point &right)
 Subtracts the given point. More...
 
const Pointoperator*= (const float &right)
 Multiplies by given scalar. More...
 
const Pointoperator/= (const float &right)
 Divides by given scalar. More...
 
std::string ToString () const
 Returns a string "[x, y]". More...
 

Public Attributes

float x
 X coord. More...
 
float y
 Y coord. More...
 

Friends

const Point operator+ (const Point &left, const Point &right)
 Adds two points. More...
 
const Point operator- (const Point &left, const Point &right)
 Subtracts two points. More...
 
const Point operator* (const float &left, const Point &right)
 Multiplies point by scalar. More...
 
const Point operator* (const Point &left, const float &right)
 Multiplies point by scalar. More...
 
const Point operator/ (const Point &left, const float &right)
 Divides point by scalar. More...
 

Detailed Description

2D point

Represents a 2D point (x, y). Contains the required methods for operating on points.

All methods are made inline to maximize optimization.

Constructor & Destructor Documentation

Math::Point::Point ( )
inline

Constructs a zero point: (0,0)

Math::Point::Point ( float  _x,
float  _y 
)
inlineexplicit

Constructs a point from given coords: (x,y)

Member Function Documentation

void Math::Point::LoadZero ( )
inline

Sets the zero point: (0,0)

float* Math::Point::Array ( )
inline

Returns the struct cast to float* array; use with care!

const float* Math::Point::Array ( ) const
inline

Returns the struct cast to const float* array; use with care!

float Math::Point::Length ( )
inline

Returns the distance from (0,0) to the point (x,y)

Point Math::Point::operator- ( ) const
inline

Returns the inverted point.

const Point& Math::Point::operator+= ( const Point right)
inline

Adds the given point.

const Point& Math::Point::operator-= ( const Point right)
inline

Subtracts the given point.

const Point& Math::Point::operator*= ( const float &  right)
inline

Multiplies by given scalar.

const Point& Math::Point::operator/= ( const float &  right)
inline

Divides by given scalar.

std::string Math::Point::ToString ( ) const
inline

Returns a string "[x, y]".

Friends And Related Function Documentation

const Point operator+ ( const Point left,
const Point right 
)
friend

Adds two points.

const Point operator- ( const Point left,
const Point right 
)
friend

Subtracts two points.

const Point operator* ( const float &  left,
const Point right 
)
friend

Multiplies point by scalar.

const Point operator* ( const Point left,
const float &  right 
)
friend

Multiplies point by scalar.

const Point operator/ ( const Point left,
const float &  right 
)
friend

Divides point by scalar.

Member Data Documentation

float Math::Point::x

X coord.

float Math::Point::y

Y coord.


The documentation for this struct was generated from the following file: