SGSolve
SGPoint Class Reference

A vector in $\mathbb{R}^n$. More...

#include <sgpoint.hpp>

Public Member Functions

 SGPoint ()
 Default constructor that sets vector equal to zero.
 
 SGPoint (double _x)
 Sets both elements of the vector equal to x.
 
 SGPoint (int n)
 Creates an n dimensional zero vector.
 
 SGPoint (int n, double _x)
 Creates an n dimensional zero vector.
 
 SGPoint (vector< double > _x)
 Creates an SGPoint from the two-vector _x.
 
 SGPoint (double _x0, double _x1)
 Creates an SGPoint with elements x and y.
 
 ~SGPoint ()
 Destructor.
 
int size () const
 Returns the number of coordinates.
 
SGPoint getNormal () const
 Returns the counter-clockwise normal vector.
 
double norm () const
 Returns the Euclidean norm.
 
double angle (const SGPoint &base) const
 Returns the angle in radians relative to base.
 
bool rotateCCW (double pi)
 Rotates the point clockwise by pi radians.
 
bool rotateCW (double pi)
 Rotates the point clockwise by pi radians.
 
bool normalize ()
 Normalizes so that the norm is one.
 
bool anyNaN () const
 Checks if any of the entries are NaN.
 
void roundPoint (double tol)
 Rounds off significant digits smaller than tol.
 
void max (const SGPoint &p)
 Takes the pointwise minimum with another SGPoint.
 
void min (const SGPoint &p)
 Takes the pointwise minimum with another SGPoint.
 
void plusWithWeight (const SGPoint &p, double w)
 Plus with weight.
 
double & operator[] (int player)
 Access operator.
 
const double & operator[] (int player) const
 Constant access operator.
 
SGPointoperator= (const SGPoint &rhs)
 Assignment operator.
 
SGPointoperator= (double d)
 Sets both coordinates equal to d.
 
SGPointoperator+= (const SGPoint &rhs)
 Augmented addition.
 
SGPointoperator-= (const SGPoint &rhs)
 Augmented subtraction.
 
SGPointoperator-= (double d)
 Augmented subtraction.
 
SGPointoperator*= (double d)
 Augmented scalar multiplication.
 
SGPointoperator/= (double d)
 Augmented scalar division.
 
const SGPoint operator+ (const SGPoint &rhs) const
 Vector addition.
 
const SGPoint operator- (const SGPoint &rhs) const
 Vector subtraction.
 
const SGPoint operator- (double d) const
 Vector subtraction.
 
double operator* (const SGPoint &rhs) const
 Dot product.
 
bool operator== (const SGPoint &rhs) const
 Equality.
 
bool operator!= (const SGPoint &rhs) const
 Not equls.
 
bool operator>= (const SGPoint &rhs) const
 Greater than or equal.
 
bool operator> (const SGPoint &rhs) const
 Strictly greater.
 
bool operator<= (const SGPoint &rhs) const
 Less than or equal.
 
bool operator< (const SGPoint &rhs) const
 Strictly less.
 
bool operator>= (double rhs) const
 Greater than or equal to a scalar.
 
bool operator> (double rhs) const
 Strictly greater than a scalar.
 
bool operator<= (double rhs) const
 Less than or equal to a scalar.
 
bool operator< (double rhs) const
 Strictly less than a scalar.
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 Serialize an SGPoint.
 

Static Public Member Functions

static double distance (const SGPoint &p0, const SGPoint &p1)
 Calculates distance between p0 and p1 in the sup-norm.
 
static SGPoint cross (const SGPoint &p0, const SGPoint &p1)
 Cross product for 3-vectors.
 
static double invertSystem (SGPoint &x, const SGPoint &b, const SGPoint &a0, const SGPoint &a1)
 Inverts a linear system. More...
 
static double intersectRay (SGPoint &intersection, SGPoint &weights, const SGPoint &pivot, const SGPoint &direction, const SGPoint &t0, const SGPoint &t1)
 Calculates intersection of a segment with a ray. More...
 
static double signedArea (const SGPoint &p0, const SGPoint &p1, const SGPoint &p2)
 Calculates determinant. More...
 

Protected Attributes

vector< double > x
 

Friends

class boost::serialization::access
 
class SGTuple
 
SGPoint operator* (double d, const SGPoint &point)
 Left-scalar multiplication.
 
SGPoint operator* (const SGPoint &point, double d)
 Right-scalar multiplication.
 
SGPoint operator/ (const SGPoint &point, double d)
 Right scalar division.
 
ostream & operator<< (ostream &out, const SGPoint &rhs)
 Output SGPoint to ostream.
 

Detailed Description

A vector in $\mathbb{R}^n$.

A simple two-dimensional vector that supports arithmetic operations.

Member Function Documentation

◆ intersectRay()

static double SGPoint::intersectRay ( SGPoint intersection,
SGPoint weights,
const SGPoint pivot,
const SGPoint direction,
const SGPoint t0,
const SGPoint t1 
)
static

Calculates intersection of a segment with a ray.

Calculates the intersection of the ray defined by $pivot+t\cdot{}direction$ with the line segment $\alpha{}t_0+(1-\alpha)t_1$ for $\alpha\in[0,1]$.

◆ invertSystem()

double SGPoint::invertSystem ( SGPoint x,
const SGPoint b,
const SGPoint a0,
const SGPoint a1 
)
static

Inverts a linear system.

Solves the system of equations $\left[\begin{array}{c}{a_0}{a_1}\end{array}\right]x=b$.

◆ signedArea()

double SGPoint::signedArea ( const SGPoint p0,
const SGPoint p1,
const SGPoint p2 
)
static

Calculates determinant.

Calculates the signed area of the parallelogram starting at $p_0$ and going in the directions $p_1$ and $p_2$.

Member Data Documentation

◆ x

vector<double> SGPoint::x
protected

Two dimensional vector of doubles.


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