GT RoboCup SSL
Soccer software, robot firmware
Geometry2d::Point Class Reference

Simple class to represent a point in 2d space. More...

Public Member Functions

const double & x () const
 
const double & y () const
 
double & x ()
 
double & y ()
 
 Point (double x=0, double y=0)
 sets the point to x,y More...
 
 Point (const Packet::Point &other)
 Implicit constructor for creating a Point from a Packet::Point.
 
 Point (const QPointF &other)
 Implicit constructor for creating a Point from a QPointF.
 
 Point (const QPoint &other)
 Implicit constructor for creating a Point from a QPoint.
 
 Point (const double *other)
 Implicit constructor for creating a Point from a double*.
 
 Point (const Eigen::Vector2d &other)
 Implicit conversion from Eigen::Vector2d.
 
 operator Eigen::Vector2d () const
 Implicit conversion to Eigen::Vector2d.
 
QPointF toQPointF () const
 to draw stuff and interface with QT
 
 operator Packet::Point () const
 
Point operator+ (Point other) const
 does vector addition adds the + operator, shorthand
 
Point operator/ (Point other) const
 see operator+ does vector division, note the operator
 
Point operator* (Point other) const
 
Point operator- (Point other) const
 see operator+ does vector subtraction, note the operator without parameter, it is the negative
 
Point operator- () const
 multiplies the point by a -1 vector
 
Pointoperator+= (Point other)
 see operator+ this modifies the value instead of returning a new value
 
Pointoperator-= (Point other)
 see operator- this modifies the value instead of returning a new value
 
Pointoperator*= (double s)
 see operator* this modifies the value instead of returning a new value
 
Pointoperator/= (double s)
 see operator/ this modifies the value instead of returning a new value
 
Point operator/ (double s) const
 adds the / operator for vectors scalar division
 
Point operator* (double s) const
 adds the * operator for vectors scalar multiplication
 
bool operator== (Point other) const
 compares two points to see if both x and y are the same adds the == operator
 
bool operator!= (Point other) const
 this is the negation of operator operator !=
 
const double & operator[] (int i) const
 
double & operator[] (int i)
 
double dot (Point p) const
 computes the dot product of this point and another. More...
 
double mag () const
 computes the magnitude of the point, as if it were a vector More...
 
double magsq () const
 computes magnitude squared this is faster than mag() More...
 
Pointclamp (double max)
 Restricts the point to a given magnitude. More...
 
Pointrotate (const Point &origin, double angle)
 rotates the point around another point by specified angle in the CCW direction More...
 
Pointrotate (double angle)
 rotates the point around the origin
 
Point rotated (double angle) const
 Like rotate(), but returns a new point instead of changing *this.
 
Point rotated (const Point &origin, double angle) const
 Returns a new Point rotated around the origin.
 
double distTo (const Point &other) const
 computes the distance from the current point to another More...
 
Point normalized (double magnitude=1.0) const
 Returns a vector with the same direction as this vector but with magnitude given, unless this vector is zero. More...
 
Point norm () const
 Alias for normalized() - matches Eigen's syntax.
 
bool nearPoint (const Point &other, double threshold) const
 Returns true if this point is within the given distance (threshold) of (pt)
 
double angle () const
 Returns the angle of this point in radians CCW from +X.
 
Point perpCW () const
 returns the perpendicular to the point, Clockwise
 
Point perpCCW () const
 returns the perpendicular to the point, Counter Clockwise
 
double angleTo (const Point &other) const
 
double cross (const Point &other) const
 
double angleBetween (const Point &other) const
 returns the angle between the two normalized points (radians)
 
bool nearlyEquals (Point other) const
 
std::string toString () const
 

Static Public Member Functions

static size_t hash (Point pt)
 Hash function for Geometry2d::Point.
 
static Point rotated (const Point &pt, const Point &origin, double angle)
 static function to use rotate
 
static Point direction (double theta)
 Returns a unit vector in the given direction (in radians)
 
static Geometry2d::Point saturate (Geometry2d::Point value, double max)
 saturates the magnitude of a vector
 

Friends

std::ostream & operator<< (std::ostream &stream, const Point &point)
 

Detailed Description

Simple class to represent a point in 2d space.

Uses floating point coordinates

Constructor & Destructor Documentation

◆ Point()

Geometry2d::Point::Point ( double  x = 0,
double  y = 0 
)
inline

sets the point to x,y

Parameters
xthe x coordinate
ythe y coordinate

Member Function Documentation

◆ clamp()

Point& Geometry2d::Point::clamp ( double  max)
inline

Restricts the point to a given magnitude.

Parameters
maxThe magnitude to restrict the vector

◆ distTo()

double Geometry2d::Point::distTo ( const Point other) const
inline

computes the distance from the current point to another

Parameters
otherthe point to find the distance to
Returns
the distance between the points

◆ dot()

double Geometry2d::Point::dot ( Point  p) const
inline

computes the dot product of this point and another.

behaves as if the points were 2d vectors

Parameters
pthe second point
Returns
the dot product of the two

◆ mag()

double Geometry2d::Point::mag ( ) const
inline

computes the magnitude of the point, as if it were a vector

Returns
the magnitude of the point

◆ magsq()

double Geometry2d::Point::magsq ( ) const
inline

computes magnitude squared this is faster than mag()

Returns
the magnitude squared

◆ normalized()

Point Geometry2d::Point::normalized ( double  magnitude = 1.0) const
inline

Returns a vector with the same direction as this vector but with magnitude given, unless this vector is zero.

If the vector is (0,0), Point(0,0) is returned

◆ operator*()

Point Geometry2d::Point::operator* ( Point  other) const
inline
Returns
(x*x,y*y)

◆ rotate()

Point& Geometry2d::Point::rotate ( const Point origin,
double  angle 
)
inline

rotates the point around another point by specified angle in the CCW direction

Parameters
originthe point to rotate around
anglethe angle in radians

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