TwiceAsNice  2019-02-18
Public Member Functions | Friends | Related Functions | List of all members
Nice::Point Class Reference

The Nice::Point class defines a point in the plane using floating point precision. More...

#include <Point.h>

Inheritance diagram for Nice::Point:
Inheritance graph
Collaboration diagram for Nice::Point:
Collaboration graph

Public Member Functions

 Point ()
 
 Point (double xpos, double ypos)
 
 Point (const Nice::PointVar &p)
 
bool isNull () const
 
double x () const
 
double y () const
 
void setX (double x)
 
void setY (double y)
 
double & rx ()
 
double & ry ()
 
double distance () const
 
Pointoperator+= (const Point &p)
 
Pointoperator-= (const Point &p)
 
Pointoperator*= (double c)
 
Pointoperator/= (double c)
 
 Point ()
 
 Point (double xpos, double ypos)
 
 Point (const Nice::PointVar &p)
 
bool isNull () const
 
double x () const
 
double y () const
 
void setX (double x)
 
void setY (double y)
 
double & rx ()
 
double & ry ()
 
double distance () const
 
Pointoperator+= (const Point &p)
 
Pointoperator-= (const Point &p)
 
Pointoperator*= (double c)
 
Pointoperator/= (double c)
 
- Public Member Functions inherited from Nice::PointVar
bool operator== (const PointVar &__rhs) const
 
bool operator< (const PointVar &__rhs) const
 
bool operator!= (const PointVar &__rhs) const
 
bool operator<= (const PointVar &__rhs) const
 
bool operator> (const PointVar &__rhs) const
 
bool operator>= (const PointVar &__rhs) const
 
bool operator== (const PointVar &__rhs) const
 
bool operator< (const PointVar &__rhs) const
 
bool operator!= (const PointVar &__rhs) const
 
bool operator<= (const PointVar &__rhs) const
 
bool operator> (const PointVar &__rhs) const
 
bool operator>= (const PointVar &__rhs) const
 

Friends

class WMatrix
 
bool operator== (const Point &, const Point &)
 
bool operator!= (const Point &, const Point &)
 
const Point operator+ (const Point &, const Point &)
 
const Point operator- (const Point &, const Point &)
 
const Point operator* (double, const Point &)
 
const Point operator* (const Point &, double)
 
const Point operator- (const Point &)
 
const Point operator/ (const Point &, double)
 
bool operator== (const Point &, const Point &)
 
bool operator!= (const Point &, const Point &)
 
const Point operator+ (const Point &, const Point &)
 
const Point operator- (const Point &, const Point &)
 
const Point operator* (double, const Point &)
 
const Point operator* (const Point &, double)
 
const Point operator- (const Point &)
 
const Point operator/ (const Point &, double)
 

Related Functions

(Note that these are not member functions.)

bool operator== (const Nice::Point &p1, const Nice::Point &p2)
 
bool operator!= (const Nice::Point &p1, const Nice::Point &p2)
 
const Nice::Point operator+ (const Nice::Point &p1, const Nice::Point &p2)
 
const Nice::Point operator- (const Nice::Point &p1, const Nice::Point &p2)
 
const Nice::Point operator* (double factor, const Nice::Point &point)
 
const Nice::Point operator* (const Nice::Point &point, double factor)
 
const Nice::Point operator- (const Nice::Point &point)
 
const Nice::Point operator/ (const Nice::Point &point, double divisor)
 
bool operator== (const Nice::Point &p1, const Nice::Point &p2)
 
bool operator!= (const Nice::Point &p1, const Nice::Point &p2)
 
const Nice::Point operator+ (const Nice::Point &p1, const Nice::Point &p2)
 
const Nice::Point operator- (const Nice::Point &p1, const Nice::Point &p2)
 
const Nice::Point operator* (double factor, const Nice::Point &point)
 
const Nice::Point operator* (const Nice::Point &point, double factor)
 
const Nice::Point operator- (const Nice::Point &point)
 
const Nice::Point operator/ (const Nice::Point &point, double divisor)
 

Additional Inherited Members

- Public Attributes inherited from Nice::PointVar
::Ice::Double xp
 
::Ice::Double yp
 

Detailed Description

The Nice::Point class defines a point in the plane using floating point precision.

A point is specified by a x coordinate and an y coordinate which can be accessed using the x() and y() functions. The coordinates of the point are specified using floating point numbers for accuracy. The isNull() function returns true if both x and y are set to 0.0. The coordinates can be set (or altered) using the setX() and setY() functions, or alternatively the rx() and ry() functions which return references to the coordinates (allowing direct manipulation).

Given a point p, the following statements are all equivalent:

p.setX(p.x() + 1.0);
p += QPointVar(1.0, 0.0);
p.rx()++;

A Nice::Point object can also be used as a vector: Addition and subtraction are defined as for vectors (each component is added separately). A Nice::Point object can also be divided or multiplied by an int or a double.

In addition, the Nice::Point class provides a constructor converting a QPointVar object into a Nice::Point object, and a corresponding toPointVar() function which returns a QPointVar copy of this point. Finally, Nice::Point objects can be streamed as well as compared.

See also
QPointVar, QPolygonF

Constructor & Destructor Documentation

◆ Point() [1/6]

Nice::Point::Point ( )
inline

◆ Point() [2/6]

Nice::Point::Point ( double  xpos,
double  ypos 
)
inline

◆ Point() [3/6]

Nice::Point::Point ( const Nice::PointVar p)
inline

◆ Point() [4/6]

Nice::Point::Point ( )

◆ Point() [5/6]

Nice::Point::Point ( double  xpos,
double  ypos 
)

◆ Point() [6/6]

Nice::Point::Point ( const Nice::PointVar p)

Member Function Documentation

◆ distance() [1/2]

double Nice::Point::distance ( ) const
inline

distance of point to the origin.

Returns
The Euclidean distance, square root of the sum of the squares of the coordiantes.
Since
2017-06-25

◆ distance() [2/2]

double Nice::Point::distance ( ) const

distance of point to the origin.

Returns
The Euclidean distance, square root of the sum of the squares of the coordiantes.
Since
2017-06-25

◆ isNull() [1/2]

bool Nice::Point::isNull ( ) const
inline

Returns true if both the x and y coordinates are set to 0.0, otherwise returns false.

◆ isNull() [2/2]

bool Nice::Point::isNull ( ) const

◆ operator*=() [1/2]

Point & Nice::Point::operator*= ( double  factor)
inline

Multiplies this point's coordinates by the given factor, and returns a reference to this point. For example:

QPointVar p(-1.1, 4.1);
p *= 2.5; // p becomes (-2.75,10.25)
See also
operator/=()

◆ operator*=() [2/2]

Point& Nice::Point::operator*= ( double  c)

◆ operator+=() [1/2]

Point & Nice::Point::operator+= ( const Point p)
inline

Adds the given point to this point and returns a reference to this point. For example:

QPointVar p( 3.1, 7.1);
QPointVar q(-1.0, 4.1);
p += q; // p becomes (2.1, 11.2)
See also
operator-=()

◆ operator+=() [2/2]

Point& Nice::Point::operator+= ( const Point p)

◆ operator-=() [1/2]

Point & Nice::Point::operator-= ( const Point p)
inline

Subtracts the given point from this point and returns a reference to this point. For example:

QPointVar p( 3.1, 7.1);
QPointVar q(-1.0, 4.1);
p -= q; // p becomes (4.1, 3.0)
See also
operator+=()

◆ operator-=() [2/2]

Point& Nice::Point::operator-= ( const Point p)

◆ operator/=() [1/2]

Point & Nice::Point::operator/= ( double  divisor)
inline

Divides both x and y by the given divisor, and returns a reference to this point. For example:

QPointVar p(-2.75, 10.25);
p /= 2.5; // p becomes (-1.1,4.1)
See also
operator*=()

◆ operator/=() [2/2]

Point& Nice::Point::operator/= ( double  c)

◆ rx() [1/2]

double& Nice::Point::rx ( )

◆ rx() [2/2]

double & Nice::Point::rx ( )
inline

Returns a reference to the x coordinate of this point.

Using a reference makes it possible to directly manipulate x. For example:

QPointVar p(1.1, 2.5);
p.rx()--; // p becomes (0.1, 2.5)
See also
x(), setX()

◆ ry() [1/2]

double& Nice::Point::ry ( )

◆ ry() [2/2]

double & Nice::Point::ry ( )
inline

Returns a reference to the y coordinate of this point.

Using a reference makes it possible to directly manipulate y. For example:

QPointVar p(1.1, 2.5);
p.ry()++; // p becomes (1.1, 3.5)
See also
y() setY()

◆ setX() [1/2]

void Nice::Point::setX ( double  x)

◆ setX() [2/2]

void Nice::Point::setX ( double  x)
inline

Sets the x coordinate of this point to the given x coordinate.

See also
x() setY()

◆ setY() [1/2]

void Nice::Point::setY ( double  y)

◆ setY() [2/2]

void Nice::Point::setY ( double  y)
inline

Sets the y coordinate of this point to the given y coordinate.

See also
y(), setX()

◆ x() [1/2]

double Nice::Point::x ( ) const
inline

Returns the x-coordinate of this point.

See also
setX(), rx()

◆ x() [2/2]

double Nice::Point::x ( ) const

◆ y() [1/2]

double Nice::Point::y ( ) const

◆ y() [2/2]

double Nice::Point::y ( ) const
inline

Returns the y-coordinate of this point.

See also
setY(), ry()

Friends And Related Function Documentation

◆ operator!=() [1/4]

bool operator!= ( const Nice::Point p1,
const Nice::Point p2 
)
related

Returns true if p1 is not equal to p2; otherwise returns false.

◆ operator!=() [2/4]

bool operator!= ( const Nice::Point p1,
const Nice::Point p2 
)
related

Returns true if p1 is not equal to p2; otherwise returns false.

◆ operator!= [3/4]

bool operator!= ( const Point p1,
const Point p2 
)
friend

◆ operator!= [4/4]

bool operator!= ( const Point p1,
const Point p2 
)
friend

◆ operator*() [1/8]

const Nice::Point operator* ( double  factor,
const Nice::Point point 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns a copy of the given point, multiplied by the given factor.

◆ operator*() [2/8]

const Nice::Point operator* ( double  factor,
const Nice::Point point 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns a copy of the given point, multiplied by the given factor.

◆ operator* [3/8]

const Point operator* ( double  c,
const Point p 
)
friend

◆ operator* [4/8]

const Point operator* ( double  c,
const Point p 
)
friend

◆ operator*() [5/8]

const Nice::Point operator* ( const Nice::Point point,
double  factor 
)
related

Returns a copy of the given point, multiplied by the given factor.

See also
Nice::Point::operator*=()

◆ operator*() [6/8]

const Nice::Point operator* ( const Nice::Point point,
double  factor 
)
related

Returns a copy of the given point, multiplied by the given factor.

See also
Nice::Point::operator*=()

◆ operator* [7/8]

const Point operator* ( const Point p,
double  c 
)
friend

◆ operator* [8/8]

const Point operator* ( const Point p,
double  c 
)
friend

◆ operator+() [1/4]

const Nice::Point operator+ ( const Nice::Point p1,
const Nice::Point p2 
)
related

Returns a Nice::Point object that is the sum of the given points, p1 and p2; each component is added separately.

See also
Nice::Point::operator+=()

◆ operator+() [2/4]

const Nice::Point operator+ ( const Nice::Point p1,
const Nice::Point p2 
)
related

Returns a Nice::Point object that is the sum of the given points, p1 and p2; each component is added separately.

See also
Nice::Point::operator+=()

◆ operator+ [3/4]

const Point operator+ ( const Point p1,
const Point p2 
)
friend

◆ operator+ [4/4]

const Point operator+ ( const Point p1,
const Point p2 
)
friend

◆ operator-() [1/8]

const Nice::Point operator- ( const Nice::Point p1,
const Nice::Point p2 
)
related

Returns a Nice::Point object that is formed by subtracting p2 from p1; each component is subtracted separately.

See also
Nice::Point::operator-=()

◆ operator-() [2/8]

const Nice::Point operator- ( const Nice::Point p1,
const Nice::Point p2 
)
related

Returns a Nice::Point object that is formed by subtracting p2 from p1; each component is subtracted separately.

See also
Nice::Point::operator-=()

◆ operator- [3/8]

const Point operator- ( const Point p1,
const Point p2 
)
friend

◆ operator- [4/8]

const Point operator- ( const Point p1,
const Point p2 
)
friend

◆ operator-() [5/8]

const Nice::Point operator- ( const Nice::Point point)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns a Nice::Point object that is formed by changing the sign of both components of the given point.

Equivalent to {Nice::Point(0,0) - point}.

◆ operator-() [6/8]

const Nice::Point operator- ( const Nice::Point point)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns a Nice::Point object that is formed by changing the sign of both components of the given point.

Equivalent to {Nice::Point(0,0) - point}.

◆ operator- [7/8]

const Point operator- ( const Point p)
friend

◆ operator- [8/8]

const Point operator- ( const Point p)
friend

◆ operator/() [1/4]

const Nice::Point operator/ ( const Nice::Point point,
double  divisor 
)
related

Returns the Nice::Point object formed by dividing both components of the given point by the given divisor.

See also
Nice::Point::operator/=()

◆ operator/() [2/4]

const Nice::Point operator/ ( const Nice::Point point,
double  divisor 
)
related

Returns the Nice::Point object formed by dividing both components of the given point by the given divisor.

See also
Nice::Point::operator/=()

◆ operator/ [3/4]

const Point operator/ ( const Point p,
double  c 
)
friend

◆ operator/ [4/4]

const Point operator/ ( const Point p,
double  c 
)
friend

◆ operator==() [1/4]

bool operator== ( const Nice::Point p1,
const Nice::Point p2 
)
related

Returns true if p1 is equal to p2; otherwise returns false.

◆ operator==() [2/4]

bool operator== ( const Nice::Point p1,
const Nice::Point p2 
)
related

Returns true if p1 is equal to p2; otherwise returns false.

◆ operator== [3/4]

bool operator== ( const Point p1,
const Point p2 
)
friend

◆ operator== [4/4]

bool operator== ( const Point p1,
const Point p2 
)
friend

◆ WMatrix

WMatrix
friend

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