DGtal  1.5.beta
LibBoard::Point Struct Reference

Struct representing a 2D point. More...

#include <Board/Point.h>

Public Member Functions

 Point ()
 
 Point (const Point &other)
 
Pointoperator= (const Point &other)=default
 
 Point (double xc, double yc)
 
Pointrotate (double angle)
 
void get (double &xout, double &yout) const
 
Point rotated (double angle) const
 
Pointrotate (double angle, const Point &center)
 
Point rotated (double angle, const Point &center) const
 
Pointoperator+= (const Point &other)
 
Pointoperator-= (const Point &other)
 
Pointoperator*= (double s)
 
Pointoperator/= (double s)
 
Point operator- ()
 
double norm () const
 

Data Fields

double x
 
double y
 

Detailed Description

Struct representing a 2D point.

The Point structure.

Examples
geometry/curves/exampleAlphaThickSegmentTgtCover.cpp, and geometry/curves/greedyAlphaThickDecomposition.cpp.

Definition at line 27 of file Point.h.

Constructor & Destructor Documentation

◆ Point() [1/3]

LibBoard::Point::Point ( )
inline

Point constructor.

Definition at line 36 of file Point.h.

36 :x(0.0),y(0.0) { }
double y
Definition: Point.h:30
double x
Definition: Point.h:29

Referenced by operator-(), and rotated().

◆ Point() [2/3]

LibBoard::Point::Point ( const Point other)
inline

Point constructor.

Parameters
otherpoint to copy

Definition at line 43 of file Point.h.

43 :x(other.x),y(other.y) { }

◆ Point() [3/3]

LibBoard::Point::Point ( double  xc,
double  yc 
)
inline

Point constructor.

Parameters
xcThe point's first coordinate.
ycThe point's second coordinate.

Definition at line 58 of file Point.h.

58 :x(xc),y(yc) { }

Member Function Documentation

◆ get()

void LibBoard::Point::get ( double &  xout,
double &  yout 
) const
inline

Get the values of the x and y values.

Parameters
xoutReference to the x to be set.
youtReference to the y to be set.

Definition at line 103 of file Point.h.

104 {
105  xout = x;
106  yout = y;
107 }

References x, and y.

◆ norm()

double LibBoard::Point::norm ( ) const
inline

Definition at line 221 of file Point.h.

222 {
223  return sqrt( x*x + y*y );
224 }

Referenced by LibBoard::Text::rotate().

◆ operator*=()

Point & LibBoard::Point::operator*= ( double  s)
inline

Definition at line 162 of file Point.h.

163 {
164  x *= s;
165  y *= s;
166  return *this;
167 }

◆ operator+=()

Point & LibBoard::Point::operator+= ( const Point other)
inline

Definition at line 146 of file Point.h.

147 {
148  x += other.x;
149  y += other.y;
150  return *this;
151 }

References x, and y.

◆ operator-()

Point LibBoard::Point::operator- ( )
inline

Definition at line 226 of file Point.h.

227 {
228  return Point( -x, -y );
229 }

References Point().

◆ operator-=()

Point & LibBoard::Point::operator-= ( const Point other)
inline

Definition at line 154 of file Point.h.

155 {
156  x -= other.x;
157  y -= other.y;
158  return *this;
159 }

References x, and y.

◆ operator/=()

Point & LibBoard::Point::operator/= ( double  s)
inline

Definition at line 170 of file Point.h.

171 {
172  x /= s;
173  y /= s;
174  return *this;
175 }

◆ operator=()

Point& LibBoard::Point::operator= ( const Point other)
default

Default assignment operator.

Parameters
otherpoint to copy.

◆ rotate() [1/2]

Point & LibBoard::Point::rotate ( double  angle)
inline

Rotate the point with a given angle around the origin (0,0)

Parameters
angleThe rotation angle.

Definition at line 190 of file Point.h.

191 {
192  double newx = cos( angle ) * Point::x - sin( angle ) * Point::y;
193  double newy = sin( angle ) * Point::x + cos( angle ) * Point::y;
194  x = newx;
195  y = newy;
196  return *this;
197 }

References x, and y.

Referenced by LibBoard::Circle::rotate(), and LibBoard::Text::rotate().

◆ rotate() [2/2]

Point & LibBoard::Point::rotate ( double  angle,
const Point center 
)
inline

Definition at line 206 of file Point.h.

207 {
208  (*this) -= center;
209  (*this).rotate( angle );
210  (*this) += center;
211  return *this;
212 }
Point center(const std::vector< Point > &points)

◆ rotated() [1/2]

Point LibBoard::Point::rotated ( double  angle) const
inline

Rotate the point with a given angle around the origin (0,0)

Parameters
angleThe rotation angle.
Returns
The rotated point.

Definition at line 200 of file Point.h.

201 {
202  return Point(*this).rotate( angle );
203 }

References Point().

Referenced by LibBoard::Ellipse::rotate().

◆ rotated() [2/2]

Point LibBoard::Point::rotated ( double  angle,
const Point center 
) const
inline

Definition at line 215 of file Point.h.

216 {
217  return Point(*this).rotate( angle, center );
218 }

References Point().

Field Documentation

◆ x

◆ y


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