geirs2Panic  Richard J. Mathar
Fits header keyword batch editor
 All Classes Files Functions Variables Macros Pages
Public Member Functions | Public Attributes | List of all members
Point2D Class Reference

A point with 2 coordinates represented in a Cartesian coordinate system. More...

#include <Point2D.h>

Inheritance diagram for Point2D:
Inheritance graph
Collaboration diagram for Point2D:
Collaboration graph

Public Member Functions

 Point2D (double x, double y)
 
 Point2D (const double xandy[2])
 
 Point2D ()
 
Point2D to (const Point2D &oth) const
 
Point2D plus (const Point2D &oth) const
 Add this point (as a vector) to another point. More...
 
Point2D turn90 () const
 
Point2D apply (const RotTrans2D &rt) const
 
double dist (const Point2D &oth) const
 
double len () const
 
double dotprod (const Point2D &oth) const
 
Point2Doperator-= (const Point2D &rhs)
 Subtract another point, interpreting both points as vectors. More...
 
Point2Doperator+= (const Point2D &rhs)
 Add another point, interpreting both points as vectors. More...
 

Public Attributes

double coord [2]
 The two Cartesian coordinates x and y of the point. More...
 

Detailed Description

A point with 2 coordinates represented in a Cartesian coordinate system.

Since
2013-07-03
Author
Richard J. Mathar

Constructor & Destructor Documentation

Point2D::Point2D ( double  x,
double  y 
)

Create a point given its two Cartesian coordinates.

Parameters
xThe x coordinate.
yThe y coordinate
Point2D::Point2D ( const double  xandy[2])

Create a point given its coordinate vector.

Parameters
xandyThe x coordinate in [0], the y coordinate in [1].
Point2D::Point2D ( )

Create a point at the origin of coordinates.

Member Function Documentation

Point2D Point2D::to ( const Point2D oth) const

Compute the direction from this point to another. Equivalent description would be to constructe the vector to the other point minus this.

Parameters
othThe other point to connect this to.
Point2D Point2D::plus ( const Point2D oth) const

Add this point (as a vector) to another point.


Parameters
oth[in]The other point to attach this to.
Returns
The point which has x and y coordinates which are sums of the x and y coordinates of this and oth.
Point2D Point2D::turn90 ( ) const

Create a point that is rotated by 90 degrees ccw .

Returns
A point with coordinates (-y,+x) if this =(+x,+y).
Point2D Point2D::apply ( const RotTrans2D rt) const

Apply a rotation-translation to this point. The effect is the same as calling RotTrans2D::apply(const Point2D &) .

Parameters
[in]rtThe rotation-translation operator to be applied.
Returns
A point with coordinates rotated then translated by rt.
double Point2D::dist ( const Point2D oth) const

Compute the distance to another point.

Parameters
othThe other reference point.
Returns
The distance between this and oth. Square root of the sum of the squared differences in both Cartesian coordinates.
double Point2D::len ( ) const

Compute the length of the vector from the origin to this point.

Returns
The distance between this and the origin.
double Point2D::dotprod ( const Point2D oth) const

Compute the dot product of this point (as a vector) with another.

Returns
The dot product this.x *oth.x +this.y*oth.y.
Point2D & Point2D::operator-= ( const Point2D rhs)

Subtract another point, interpreting both points as vectors.


Conceptionally this is (up to a sign flip or up to a role reversal) the same as the function to(const Point2D &). So the same result would be obtained by the call rhs.to(*this).

Parameters
rhsThe point to be subtracted.
Returns
A point where coordinates are individually reduced by those of rhs.
Point2D & Point2D::operator+= ( const Point2D rhs)

Add another point, interpreting both points as vectors.


Parameters
rhsThe point to be added.
Returns
A point where coordinates are individually extended by those of rhs.

Member Data Documentation

double Point2D::coord[2]

The two Cartesian coordinates x and y of the point.