WINDEX
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
cxy Class Reference

2D point or vector More...

#include <cxy.h>

Public Member Functions

 cxy (double X, double Y)
 
 cxy (const cxy &xy)
 
cxy vect (const cxy &other) const
 vector from this point to other More...
 
double dist2 (const cxy &other) const
 distance squared from this point to other More...
 
double tclosest (const cxy &end1, const cxy &end2) const
 
cxy closest (const cxy &end1, const cxy &end2) const
 
double dis2toline (const cxy &end1, const cxy &end2) const
 distance squared from this point to nearest point on line segment More...
 
bool isInside (const std::vector< cxy > &polygon) const
 true if point inside polygon
 
bool isValid () const
 
void invalidate ()
 
void zoom (float ratio)
 
bool operator== (const cxy &other) const
 
cxy operator+ (const cxy &other) const
 
cxy operator- (const cxy &other) const
 
cxyoperator*= (float s)
 
cxyoperator*= (const cxy &other)
 
cxyoperator+= (const cxy &other)
 
cxyoperator/= (float s)
 

Static Public Member Functions

static cxy enclosingWidthHeight (const std::vector< cxy > &polygon)
 
static bool isIntersection (cxy &p, const cxy &a, const cxy &b, const cxy &c, const cxy &d)
 true if line segments intersect More...
 
static bool isIntersect (cxy &p1, cxy &q1, cxy &p2, cxy &q2)
 
static double angle (const cxy &a, const cxy &b, const cxy &c, const cxy &d)
 angle between line segments, radians More...
 
static double clockwise (const cxy &a, const cxy &b, const cxy &c)
 clockwise turn going from a to b to c, radians More...
 

Public Attributes

double x
 
double y
 

Friends

std::ostream & operator<< (std::ostream &os, cxy p)
 

Detailed Description

2D point or vector

Member Function Documentation

◆ angle()

static double cxy::angle ( const cxy a,
const cxy b,
const cxy c,
const cxy d 
)
inlinestatic

angle between line segments, radians

Parameters
a,bline segment
c,dline segment
Returns
angle in radians

◆ clockwise()

static double cxy::clockwise ( const cxy a,
const cxy b,
const cxy c 
)
inlinestatic

clockwise turn going from a to b to c, radians

Parameters
a
b
c
Returns
angle in radians

◆ dis2toline()

double cxy::dis2toline ( const cxy end1,
const cxy end2 
) const
inline

distance squared from this point to nearest point on line segment

Parameters
end1line segment endpoint
end2line segment endpoint
Returns

◆ dist2()

double cxy::dist2 ( const cxy other) const
inline

distance squared from this point to other

Parameters
other
Returns

◆ isIntersection()

static bool cxy::isIntersection ( cxy p,
const cxy a,
const cxy b,
const cxy c,
const cxy d 
)
inlinestatic

true if line segments intersect

Parameters
[out]ppoint of intersection
[in]a,bline segment
[in]c,dline segment
Returns
true if line segments intersect
       intersection point

       double det = A1 * B2 - A2 * B1
    if (det == 0) {

Lines are parallel } else { double x = (B2 * C1 - B1 * C2) / det double y = (A1 * C2 - A2 * C1) / det }

◆ vect()

cxy cxy::vect ( const cxy other) const
inline

vector from this point to other

Parameters
other
Returns

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