Kig Python Scripting API Documentation

Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
Coordinate Class Reference

The Coordinate class is the basic class representing a 2D location by its x and y components. More...

Public Member Functions

 Coordinate (double x, double y)
 Constructor. More...
 
 Coordinate (const Coordinate &p)
 Copy Constructor. More...
 
 Coordinate ()
 Default Constructor. More...
 
bool valid () const
 Return whether this is a valid Coordinate. More...
 
double distance (const Coordinate &p) const
 Distance to another Coordinate.
 
double length () const
 Length. More...
 
double squareLength () const
 Square length. More...
 
const Coordinate operator- () const
 Inverse. More...
 
const Coordinate orthogonal () const
 Orthogonal. More...
 
const Coordinate round () const
 Round. More...
 
const Coordinate normalize (double length=1) const
 Normalize. More...
 
Coordinateoperator+= (const Coordinate &c)
 Add. More...
 
Coordinateoperator-= (const Coordinate &c)
 Subtract. More...
 
Coordinateoperator*= (double r)
 Scale. More...
 
Coordinateoperator*= (int r)
 Scale. More...
 
Coordinateoperator/= (double r)
 Scale. More...
 

Static Public Member Functions

static Coordinate invalidCoord ()
 Create an invalid Coordinate. More...
 

Public Attributes

double x
 X Component. More...
 
double y
 Y Component. More...
 

Friends

const Coordinate operator+ (const Coordinate &a, const Coordinate &b)
 Add. More...
 
const Coordinate operator- (const Coordinate &a, const Coordinate &b)
 Subtract. More...
 
const Coordinate operator* (const Coordinate &a, double r)
 Scale. More...
 
const Coordinate operator/ (const Coordinate &a, double r)
 Scale. More...
 
double operator* (const Coordinate &a, const Coordinate &b)
 Scalar Product. More...
 
bool operator== (const Coordinate &, const Coordinate &)
 Equal. More...
 
bool operator!= (const Coordinate &, const Coordinate &)
 Not Equal. More...
 

Detailed Description

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..

Constructor & Destructor Documentation

◆ Coordinate() [1/3]

Coordinate::Coordinate ( double  x,
double  y 
)

Constructor.

Construct a new Coordinate, with a given x and y value.

◆ Coordinate() [2/3]

Coordinate::Coordinate ( const Coordinate p)

Copy Constructor.

Construct a new Coordinate, and give it the same value as p.

◆ Coordinate() [3/3]

Coordinate::Coordinate ( )

Default Constructor.

Constructs a new Coordinate, with x and y initialized to 0.

Member Function Documentation

◆ invalidCoord()

static Coordinate Coordinate::invalidCoord ( )
static

Create an invalid Coordinate.

This is a special value of a Coordinate that signals that something went wrong..

See also
Coordinate::valid

◆ length()

double Coordinate::length ( ) const

Length.

Returns the length or norm of this coordinate. I.e. return the distance from this Coordinate to the origin.

See also
squareLength

◆ normalize()

const Coordinate Coordinate::normalize ( double  length = 1) const

Normalize.

This sets the length to length, while keeping the x/y ratio untouched...

◆ operator*=() [1/2]

Coordinate& Coordinate::operator*= ( double  r)

Scale.

Scales this Coordinate by a factor r

◆ operator*=() [2/2]

Coordinate& Coordinate::operator*= ( int  r)

Scale.

Scales this Coordinate by a factor r

◆ operator+=()

Coordinate& Coordinate::operator+= ( const Coordinate c)

Add.

Add c to this Coordinate

◆ operator-()

const Coordinate Coordinate::operator- ( ) const

Inverse.

Returns the inverse of this Coordinate.

◆ operator-=()

Coordinate& Coordinate::operator-= ( const Coordinate c)

Subtract.

Subtract c from this Coordinate

◆ operator/=()

Coordinate& Coordinate::operator/= ( double  r)

Scale.

Scales this Coordinate by a factor 1/r

◆ orthogonal()

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;

◆ round()

const Coordinate Coordinate::round ( ) const

Round.

Returns this coordinate, rounded to the nearest integral values.

◆ squareLength()

double Coordinate::squareLength ( ) const

Square length.

Equivalent to the square of length, but a bit more efficient because no square root has to be calculated.

See also
length

References x, and y.

◆ valid()

bool Coordinate::valid ( ) const

Return whether this is a valid Coordinate.

See also
Coordinate::invalidCoord

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const Coordinate ,
const Coordinate  
)
friend

Not Equal.

Tests two Coordinates for inequality.

◆ operator* [1/2]

const Coordinate operator* ( const Coordinate a,
double  r 
)
friend

Scale.

Returns this a, scaled by a factor of r.

◆ operator* [2/2]

double operator* ( const Coordinate a,
const Coordinate b 
)
friend

Scalar Product.

Returns the scalar product of a and b.

◆ operator+

const Coordinate operator+ ( const Coordinate a,
const Coordinate b 
)
friend

Add.

Returns the sum of a and b.

◆ operator-

const Coordinate operator- ( const Coordinate a,
const Coordinate b 
)
friend

Subtract.

Returns the difference between a and b.

◆ operator/

const Coordinate operator/ ( const Coordinate a,
double  r 
)
friend

Scale.

Returns a, scaled by a factor of 1/r.

◆ operator==

bool operator== ( const Coordinate ,
const Coordinate  
)
friend

Equal.

Tests two Coordinates for equality.

Member Data Documentation

◆ x

double Coordinate::x

X Component.

The X Component of this Coordinate.

Referenced by squareLength().

◆ y

double Coordinate::y

Y Component.

The Y Component of this Coordinate.

Referenced by squareLength().

KDE Logo
This file is part of the documentation for tdelibs .
Documentation copyright © 1996-2002 the KDE developers.
Generated on Tue Feb 25 2025 13:46:37 by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2001