Colobot
Loading...
Searching...
No Matches
Math::Point Struct Reference

2D point More...

#include <src/math/point.h>

Public Member Functions

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

Public Attributes

float x
 X coord.
float y
 Y coord.

Friends

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

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

◆ Point() [1/2]

Math::Point::Point ( )
inline

Constructs a zero point: (0,0).

◆ Point() [2/2]

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

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

Member Function Documentation

◆ LoadZero()

void Math::Point::LoadZero ( )
inline

Sets the zero point: (0,0).

◆ Array() [1/2]

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

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

◆ Array() [2/2]

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

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

◆ Length()

float Math::Point::Length ( )
inline

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

◆ operator-()

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

Returns the inverted point.

◆ operator+=()

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

Adds the given point.

◆ operator-=()

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

Subtracts the given point.

◆ operator*=()

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

Multiplies by given scalar.

◆ operator/=()

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

Divides by given scalar.

◆ ToString()

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

Returns a string "[x, y]".

◆ operator+

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

Adds two points.

◆ operator-

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

Subtracts two points.

◆ operator* [1/2]

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

Multiplies point by scalar.

◆ operator* [2/2]

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

Multiplies point by scalar.

◆ operator/

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

Divides point by scalar.

Member Data Documentation

◆ x

float Math::Point::x

X coord.

◆ y

float Math::Point::y

Y coord.


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