14#ifndef _BOARD_POINT_H_
15#define _BOARD_POINT_H_
18#include "DGtal/io/Color.h"
58 Point(
double xc,
double yc ):x(xc),y(yc) { }
65 inline Point & rotate(
double angle );
73 inline void get(
double & xout,
double & yout )
const;
84 inline Point & rotate(
double angle,
const Point & center );
98 inline double norm()
const;
103Point::get(
double & xout,
double & yout )
const
112 return Point( a.x + b.x, a.y + b.y );
118 return Point( a.x - b.x, a.y - b.y );
124 return a.x * b.x + a.y * b.y;
130 return Point( p.x * s, p.y * s );
136 return Point( s * p.x, s * p.y );
142 return Point( p.x / s, p.y / s );
146Point::operator+=(
const Point & other )
154Point::operator-=(
const Point & other )
162Point::operator*=(
double s )
170Point::operator/=(
double s )
180 return ( a.x == b.x ) && ( a.y == b.y ) ;
186 return ( a.x != b.x ) || ( a.y != b.y ) ;
190Point::rotate(
double angle )
192 double newx = cos( angle ) * Point::x - sin( angle ) * Point::y;
193 double newy = sin( angle ) * Point::x + cos( angle ) * Point::y;
200Point::rotated(
double angle )
const
202 return Point(*this).rotate( angle );
206Point::rotate(
double angle,
const Point & center )
209 (*this).rotate( angle );
215Point::rotated(
double angle,
const Point & center )
const
217 return Point(*this).rotate( angle, center );
223 return sqrt( x*x + y*y );
228 return Point( -x, -y );
Point operator+(const Point &a, const Point &b)
Point operator/(const Point &p, double s)
bool operator!=(const Point &a, const Point &b)
bool operator==(const Point &a, const Point &b)
double operator*(const Point &a, const Point &b)
Struct representing a 2D point.
Point & operator-=(const Point &other)
Point & operator+=(const Point &other)
Point & operator/=(double s)
void get(double &xout, double &yout) const
Point & operator*=(double s)
Point rotated(double angle) const
Point(double xc, double yc)
Point(const Point &other)
Point & operator=(const Point &other)=default