|
Kig Python Scripting API Documentation |
||||
|
The Coordinate class is the basic class representing a 2D location by its x and y components. More...
#include <coordinate.h>
Public Member Functions | |
| Coordinate (double x, double y) | |
| Constructor. | |
| Coordinate (const Coordinate &p) | |
| Copy Constructor. | |
| Coordinate () | |
| bool | valid () const |
| Return whether this is a valid Coordinate. | |
| double | distance (const Coordinate &p) const |
| Distance to another Coordinate. | |
| double | length () const |
| Length. | |
| double | squareLength () const |
| Square length. | |
| const Coordinate | operator- () const |
| Inverse. | |
| const Coordinate | orthogonal () const |
| Orthogonal. | |
| const Coordinate | round () const |
| Round. | |
| const Coordinate | normalize (double length=1) const |
| Normalize. | |
| Coordinate & | operator+= (const Coordinate &c) |
| Add. | |
| Coordinate & | operator-= (const Coordinate &c) |
| Subtract. | |
| Coordinate & | operator*= (double r) |
| Scale. | |
| Coordinate & | operator*= (int r) |
| Scale. | |
| Coordinate & | operator/= (double r) |
| Scale. | |
Static Public Member Functions | |
| static Coordinate | invalidCoord () |
| Create an invalid Coordinate. | |
Public Attributes | |
| double | x |
| X Component. | |
| double | y |
| Y Component. | |
Friends | |
| const Coordinate | operator+ (const Coordinate &a, const Coordinate &b) |
| Add. | |
| const Coordinate | operator- (const Coordinate &a, const Coordinate &b) |
| Subtract. | |
| const Coordinate | operator* (const Coordinate &a, double r) |
| Scale. | |
| const Coordinate | operator/ (const Coordinate &a, double r) |
| Scale. | |
| double | operator* (const Coordinate &a, const Coordinate &b) |
| Scalar Product. | |
| bool | operator== (const Coordinate &, const Coordinate &) |
| Equal. | |
| bool | operator!= (const Coordinate &, const Coordinate &) |
| Not Equal. | |
The Coordinate class is the basic class representing a 2D location by its x and y components.
It has all relevant arithmetic operators properly defined, and should be straightforward to use..
| Coordinate::Coordinate | ( | double | x, |
| double | y ) |
Constructor.
Construct a new Coordinate, with a given x and y value.
Referenced by Coordinate(), Coordinate(), distance(), invalidCoord(), normalize(), operator!=, operator*, operator*, operator*=(), operator*=(), operator+, operator+=(), operator-(), operator-, operator-=(), operator/, operator/=(), operator==, orthogonal(), and round().
| Coordinate::Coordinate | ( | const Coordinate & | p | ) |
Copy Constructor.
Construct a new Coordinate, and give it the same value as p.
References Coordinate().
|
static |
Create an invalid Coordinate.
This is a special value of a Coordinate that signals that something went wrong..
References Coordinate().
| double Coordinate::length | ( | ) | const |
Length.
Returns the length or norm of this coordinate. I.e. return the distance from this Coordinate to the origin.
Referenced by normalize().
| const Coordinate Coordinate::normalize | ( | double | length = 1 | ) | const |
Normalize.
This sets the length to length, while keeping the x/y ratio untouched...
References Coordinate(), and length().
| Coordinate & Coordinate::operator*= | ( | double | r | ) |
| Coordinate & Coordinate::operator*= | ( | int | r | ) |
| Coordinate & Coordinate::operator+= | ( | const Coordinate & | c | ) |
| const Coordinate Coordinate::operator- | ( | ) | const |
| Coordinate & Coordinate::operator-= | ( | const Coordinate & | c | ) |
| Coordinate & Coordinate::operator/= | ( | double | r | ) |
| const Coordinate Coordinate::orthogonal | ( | ) | const |
Orthogonal.
Returns a vector which is orthogonal on this vector. This relation always holds:
Coordinate a = ...; assert( a*a.orthogonal() ) == 0;
References Coordinate().
| const Coordinate Coordinate::round | ( | ) | const |
| double Coordinate::squareLength | ( | ) | const |
| bool Coordinate::valid | ( | ) | const |
Return whether this is a valid Coordinate.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
| double Coordinate::x |
| double Coordinate::y |