Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
datatypes::Point2D Class Reference

#include <Point2D.hpp>

Inheritance diagram for datatypes::Point2D:
Inheritance graph
[legend]

Public Types

typedef value_type floatingpoint_type
 The type of the stored x and y coordinates. An alias for value_type. More...
 
typedef double value_type
 The type of the stored x and y coordinates. More...
 

Public Member Functions

virtual const UINT32 getUsedMemory () const
 
 Point2D ()
 
 Point2D (value_type x, value_type y)
 
Accessor methods for information about this point
bool isZero () const
 
value_type getX () const
 
value_type getY () const
 
value_type dist () const
 
value_type getDist () const
 
value_type length () const
 
value_type angle () const
 
value_type getAngle () const
 
void toPolar (value_type &dist, value_type &angle) const
 
std::pair< value_type, value_typetoPolar () const
 
Point2D normalized () const
 
Point2D rotated (value_type angle_rad) const
 
Setter methods for changing this point

Returns the x/y components of this class, converted into a Point3D object with zero z-component.

void setX (value_type x)
 
void setY (value_type y)
 
void setXY (value_type x, value_type y)
 
void normalize ()
 
void rotate (value_type angle)
 
void setPolar (value_type dist, value_type angle)
 
Point2Doperator*= (value_type factor)
 
Point2Doperator+= (const Point2D &point)
 
Point2Doperator-= (const Point2D &point)
 
Point2Doperator/= (value_type divisor)
 
Geometrical relations to other objects
value_type dist (const Point2D &point) const
 
value_type distSquare (const Point2D &point) const
 
value_type angle (const Point2D &point) const
 
Serialization
std::istream & read (std::istream &is, UINT32 version)
 Reads a Point2D from an input stream. More...
 
void read (const BYTE *&buf, UINT32 version)
 Reads a Point2D from a memory buffer and increments the buffer pointer. More...
 
std::ostream & write (std::ostream &os, UINT32 version) const
 Writes a Point2D to an output stream. More...
 
void write (BYTE *&buf, UINT32 version) const
 Writes a Point2D to a memory buffer and increments the buffer pointer. More...
 
std::string toString (UINT16 digits=2) const
 Text output for debugging. More...
 
- Public Member Functions inherited from datatypes::BasicData
 BasicData ()
 
UINT16 getDatatype ()
 
UINT16 getSourceId ()
 
virtual void setSourceId (UINT16 id)
 
virtual ~BasicData ()
 

Static Public Member Functions

static Point2D fromPolar (value_type dist, value_type angle)
 

Private Attributes

value_type m_x
 
value_type m_y
 

Friends

bool operator!= (const Point2D &, const Point2D &)
 
const Point2D operator* (value_type, const Point2D &)
 
const Point2D operator* (const Point2D &, value_type)
 
Point2D::value_type operator* (const Point2D &p1, const Point2D &p2)
 
const Point2D operator+ (const Point2D &, const Point2D &)
 
const Point2D operator- (const Point2D &, const Point2D &)
 
const Point2D operator- (const Point2D &)
 
const Point2D operator/ (const Point2D &, value_type)
 
bool operator== (const Point2D &, const Point2D &)
 

Additional Inherited Members

- Protected Attributes inherited from datatypes::BasicData
UINT16 m_datatype
 
UINT16 m_sourceId
 

Detailed Description

Definition at line 27 of file Point2D.hpp.

Member Typedef Documentation

The type of the stored x and y coordinates. An alias for value_type.

Definition at line 34 of file Point2D.hpp.

The type of the stored x and y coordinates.

Definition at line 31 of file Point2D.hpp.

Constructor & Destructor Documentation

datatypes::Point2D::Point2D ( )
inline

Constructs a null point, i.e. with coordinates (0.0, 0.0)

Definition at line 41 of file Point2D.hpp.

datatypes::Point2D::Point2D ( value_type  x,
value_type  y 
)
inline

Constructs a point with the given coordinates (x, y).

Definition at line 47 of file Point2D.hpp.

Member Function Documentation

Point2D::value_type datatypes::Point2D::angle ( ) const
inline

Returns the polar angle of this point, which is the angle from the x-axis to this point. An alias for getAngle().

Definition at line 358 of file Point2D.hpp.

Point2D::value_type datatypes::Point2D::angle ( const Point2D point) const
inline

Returns the angle between this and another vector

Definition at line 363 of file Point2D.hpp.

Point2D::value_type datatypes::Point2D::dist ( ) const
inline

Returns the Euclidian distance to the origin, sqrt(x^2+y^2). An alias for getDist().

Definition at line 353 of file Point2D.hpp.

Point2D::value_type datatypes::Point2D::dist ( const Point2D point) const

Returns the Euclidian distance to the given point, sqrt( (x_1-x_2)^2 + (y_1-y_2)^2 ).

Definition at line 13 of file Point2D.cpp.

Point2D::value_type datatypes::Point2D::distSquare ( const Point2D point) const

Returns the Euclidian distance to the given point, sqrt( (x_1-x_2)^2 + (y_1-y_2)^2 ). Returns the square of the Euclidian distance to the given Point, (x_1-x_2)^2 + (y_1-y_2)^2.

Definition at line 18 of file Point2D.cpp.

Point2D datatypes::Point2D::fromPolar ( value_type  dist,
value_type  angle 
)
static

Returns a newly constructed Point2D that is a cartesian representation of the given polar coordinates.

Definition at line 25 of file Point2D.cpp.

value_type datatypes::Point2D::getAngle ( ) const
inline

Returns the polar angle of this point, which is the angle from the x-axis to this point.

Definition at line 92 of file Point2D.hpp.

value_type datatypes::Point2D::getDist ( ) const
inline

Returns the Euclidian distance to the origin, sqrt(x^2+y^2).

Definition at line 81 of file Point2D.hpp.

virtual const UINT32 datatypes::Point2D::getUsedMemory ( ) const
inlinevirtual

Constructs a point from the given ScanPoint Constructs a point from the given Point3D. Its z-coordinate will be ignored.

Implements datatypes::BasicData.

Definition at line 59 of file Point2D.hpp.

value_type datatypes::Point2D::getX ( ) const
inline

Returns the x-coordinate of this point.

Definition at line 70 of file Point2D.hpp.

value_type datatypes::Point2D::getY ( ) const
inline

Returns the y-coordinate of this point.

Definition at line 73 of file Point2D.hpp.

bool datatypes::Point2D::isZero ( ) const
inline

Returns true if this point is zero in terms of the machine precision, that is, its value is exactly zero or "almost zero".

Definition at line 296 of file Point2D.hpp.

value_type datatypes::Point2D::length ( ) const
inline

Same as dist()

Definition at line 84 of file Point2D.hpp.

void datatypes::Point2D::normalize ( )

Normalizes this vector (point is treated as a vector here) to length 1.0. If the vector has zero length (isZero() returns true), it will be left unchanged.

Definition at line 53 of file Point2D.cpp.

Point2D datatypes::Point2D::normalized ( ) const

Calculates the normalized form of this vector (point is considered as a vector here) and returns it. If the vector has zero length (isZero() returns true), it will be left unchanged.

Definition at line 46 of file Point2D.cpp.

Point2D & datatypes::Point2D::operator*= ( value_type  factor)
inline

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

Definition at line 267 of file Point2D.hpp.

Point2D & datatypes::Point2D::operator+= ( const Point2D point)
inline

Adds the given point to this point and returns a reference to this point.

Definition at line 274 of file Point2D.hpp.

Point2D & datatypes::Point2D::operator-= ( const Point2D point)
inline

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

Definition at line 281 of file Point2D.hpp.

Point2D & datatypes::Point2D::operator/= ( value_type  divisor)
inline

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

Definition at line 288 of file Point2D.hpp.

std::istream& datatypes::Point2D::read ( std::istream &  is,
UINT32  version 
)

Reads a Point2D from an input stream.

Parameters
isThe input stream
version1 == compressed meter values, 4 bytes total; 2 == float values, 8 bytes total
void datatypes::Point2D::read ( const BYTE *&  buf,
UINT32  version 
)

Reads a Point2D from a memory buffer and increments the buffer pointer.

Parameters
bufThe memory buffer
version1 == compressed meter values, 4 bytes total; 2 == float values, 8 bytes total
void datatypes::Point2D::rotate ( value_type  angle)

Rotates this point around the orign (0,0) Same as rotated, but modifies the content.

Definition at line 33 of file Point2D.cpp.

Point2D datatypes::Point2D::rotated ( value_type  angle_rad) const

Rotate the given point by the given angle around (0,0) and returns the rotated point.

This method implements an "active rotation matrix".

In other words: A positive rotation of the point (1,0) by the angle +pi/2 results in the point (0,1). Watch out: If the rotation is defined differently, another point (0,-1) might have been expected, but this function is implemented to return (0,1) here.

Definition at line 38 of file Point2D.cpp.

void datatypes::Point2D::setPolar ( value_type  dist,
value_type  angle 
)
inline

Sets the coordinates of this point from the given polar coordinates.

Definition at line 261 of file Point2D.hpp.

void datatypes::Point2D::setX ( value_type  x)
inline

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

Definition at line 140 of file Point2D.hpp.

void datatypes::Point2D::setXY ( value_type  x,
value_type  y 
)
inline

Sets the x- and y-coordinates of this point to the given coordinates.

Definition at line 147 of file Point2D.hpp.

void datatypes::Point2D::setY ( value_type  y)
inline

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

Definition at line 143 of file Point2D.hpp.

void datatypes::Point2D::toPolar ( Point2D::value_type r,
Point2D::value_type psi 
) const
inline

Calculates the polar coordinates of this point and writes them to the given arguments. dist will contain the distance of this point to the origin, and angle will contain the polar angle from the x-axis to this point.

Definition at line 371 of file Point2D.hpp.

std::pair< Point2D::value_type, Point2D::value_type > datatypes::Point2D::toPolar ( ) const
inline

Returns the polar coordinates of this point as a pair of distance and angle. The returned value's component "first" is the distance of this point to the origin, and the returned value's component "second" is the polar angle from the x-axis to this point. You can use this as follows:

std::pair<value_type,value_type> x = p.toPolar(); cout << "Distance=" << x.first << "; Angle=" << x.second;

Definition at line 377 of file Point2D.hpp.

std::string datatypes::Point2D::toString ( UINT16  digits = 2) const

Text output for debugging.

Wandlung in einen String. digits = Anzahl der Nachkommastellen.

Definition at line 75 of file Point2D.cpp.

std::ostream& datatypes::Point2D::write ( std::ostream &  os,
UINT32  version 
) const

Writes a Point2D to an output stream.

Parameters
osThe output stream
version1 == compressed meter values, 4 bytes total; 2 == float values, 8 bytes total
void datatypes::Point2D::write ( BYTE *&  buf,
UINT32  version 
) const

Writes a Point2D to a memory buffer and increments the buffer pointer.

Parameters
bufThe memory buffer
version1 == compressed meter values, 4 bytes total; 2 == float values, 8 bytes total

Friends And Related Function Documentation

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

Definition at line 311 of file Point2D.hpp.

const Point2D operator* ( Point2D::value_type  factor,
const Point2D p 
)
friend

Definition at line 331 of file Point2D.hpp.

const Point2D operator* ( const Point2D p,
Point2D::value_type  factor 
)
friend

Definition at line 326 of file Point2D.hpp.

Point2D::value_type operator* ( const Point2D p1,
const Point2D p2 
)
friend

Definition at line 336 of file Point2D.hpp.

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

Definition at line 316 of file Point2D.hpp.

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

Definition at line 321 of file Point2D.hpp.

const Point2D operator- ( const Point2D p)
friend

Definition at line 341 of file Point2D.hpp.

const Point2D operator/ ( const Point2D p,
Point2D::value_type  divisor 
)
friend

Definition at line 346 of file Point2D.hpp.

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

Definition at line 303 of file Point2D.hpp.

Member Data Documentation

value_type datatypes::Point2D::m_x
private

Definition at line 37 of file Point2D.hpp.

value_type datatypes::Point2D::m_y
private

Definition at line 38 of file Point2D.hpp.


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


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Mon Oct 26 2020 03:27:30