DrawKit
Vector and illustration framework for Mac OS X
Classes | Typedefs | Enumerations | Functions
Geom Namespace Reference

Classes

class  Eigen
 Given a matrix (ignoring the translation) this returns the eigen values and vectors. More...
 
class  Matrix
 The Matrix class. More...
 
class  Point
 Cartesian point. More...
 
class  Rotate
 Notionally an Geom::Matrix corresponding to rotation about the origin. More...
 
class  Scale
 
class  Translate
 

Typedefs

typedef double Coord
 A "real" type with sufficient precision for coordinates. More...
 

Enumerations

enum  Dim2 { X =0, Y =1 }
 

Functions

Point abs (Point const &b)
 
double angle_between (Point const a, Point const b)
 compute the angle turning from a to b (signed). More...
 
void assert_close (Matrix const &a, Matrix const &b)
 
double atan2 (Point const p)
 
int bezier_fit_cubic (Point bezier[], Point const data[], int len, double error)
 
int bezier_fit_cubic_full (Point bezier[], int split_points[], Point const data[], int len, Point const &tHat1, Point const &tHat2, double error, unsigned max_beziers)
 
int bezier_fit_cubic_r (Point bezier[], Point const data[], int len, double error, unsigned max_beziers)
 
Point bezier_pt (unsigned degree, Point const V[], double t)
 
Coord cross (Point const &a, Point const &b)
 Defined as dot(a, b.cw()). More...
 
template<typename iterator >
static void cubic_bezier_poly_coeff (iterator b, Point *pc)
 
Point darray_left_tangent (Point const d[], unsigned const len)
 
Point darray_left_tangent (Point const d[], unsigned const len, double const tolerance_sq)
 
Point darray_right_tangent (Point const d[], unsigned const length, double const tolerance_sq)
 
Coord dist_sq (Point const &a, Point const &b)
 compute the square of the distance between points a and b. More...
 
Coord distance (Point const &a, Point const &b)
 compute the euclidean distance between points a and b. More...
 
Coord dot (Point const &a, Point const &b)
 compute the dot product (inner product) between the vectors a and b. More...
 
Matrix elliptic_quadratic_form (Matrix const &m)
 Given a matrix m such that unit_circle = m*x, this returns the quadratic form x*A*x = 1. More...
 
double expansion (Matrix const &m)
 
Matrix from_basis (const Point x_basis, const Point y_basis, const Point offset=Point(0, 0))
 
Matrix identity ()
 
bool is_unit_vector (Point const &p)
 
bool is_zero (Point const &p)
 
Coord L1 (Point const &p)
 
Coord L2 (Point const &p)
 Compute the L2, or euclidean, norm of p. More...
 
Coord L2sq (Point const &p)
 Compute the square of L2 norm of p. More...
 
Point Lerp (double const t, Point const a, Point const b)
 Given two points and a parameter t [0, 1], return a point proportionally from a to b by t. More...
 
double LInfty (Point const &p)
 
bool matrix_equalp (Matrix const &m0, Matrix const &m1, Geom::Coord const epsilon)
 
void matrix_print (const char *say, Matrix const &m)
 
bool operator!= (Matrix const &a, Matrix const &b)
 
bool operator!= (Point const &a, Point const &b)
 
Matrix operator* (Scale const &s, Translate const &t)
 
Matrix operator* (Scale const &s, Matrix const &m)
 
Point operator* (Point const &v, Translate const &t)
 
Matrix operator* (Rotate const &a, Matrix const &b)
 
Translate operator* (Translate const &a, Translate const &b)
 
Matrix operator* (Translate const &t, Scale const &s)
 
Matrix operator* (Translate const &t, Rotate const &r)
 
Point operator* (Point const &p, Scale const &s)
 
Matrix operator* (Translate const &t, Matrix const &m)
 
Scale operator* (Scale const &a, Scale const &b)
 
Matrix operator* (Matrix const &m, Translate const &t)
 
Matrix operator* (Matrix const &m, Scale const &s)
 
Matrix operator* (Matrix const &m, Rotate const &r)
 
Point operator* (Point const &v, Rotate const &r)
 
Rotate operator* (Rotate const &a, Rotate const &b)
 
Point operator* (double const s, Point const &p)
 
Point operator* (Point const &p, double const s)
 
Matrix operator* (Matrix const &a, Matrix const &b)
 
Point operator* (Point const &v, Matrix const &m)
 
Point operator+ (Point const &a, Point const &b)
 
Point operator- (Point const &a, Point const &b)
 
Point operator- (Point const &a)
 
Point operator/ (Point const &v, Translate const &t)
 
Translate operator/ (Translate const &a, Translate const &b)
 
Matrix operator/ (Translate const &t, Scale const &s)
 
Matrix operator/ (Translate const &t, Rotate const &r)
 
Point operator/ (Point const &p, Scale const &s)
 
Scale operator/ (Scale const &a, Scale const &b)
 
Matrix operator/ (Matrix const &m, Scale const &s)
 
Matrix operator/ (Matrix const &a, Matrix const &b)
 
Point operator/ (Point const &v, Rotate const &r)
 
Rotate operator/ (Rotate const &a, Rotate const &b)
 
Point operator/ (Point const &p, double const s)
 
Point operator/ (double const s, Point const &p)
 
Point operator/ (Point const &p, Matrix const &m)
 
std::ostream & operator<< (std::ostream &out_file, const Geom::Point &in_pnt)
 A function to print out the Point. More...
 
std::ostream & operator<< (std::ostream &out_file, const Geom::Matrix &m)
 A function to print out the Matrix (for debugging) More...
 
bool operator<= (Point const &a, Point const &b)
 This is a lexicographical ordering for points. More...
 
bool operator== (Matrix const &a, Matrix const &b)
 
bool operator== (Point const &a, Point const &b)
 
Point operator^ (Point const &a, Point const &b)
 This is a rotation (sort of). More...
 
bool point_equalp (Point const &a, Point const &b, double const eps)
 
Point rot90 (Point const &p)
 Returns p * Geom::rotate_degrees(90), but more efficient. More...
 
bool rotate_equalp (Geom::Rotate const &a, Geom::Rotate const &b, double const eps)
 
Translate to_translate (Matrix const &m)
 
bool transform_equalp (Matrix const &m0, Matrix const &m1, Geom::Coord const epsilon)
 
bool translate_equalp (Matrix const &m0, Matrix const &m1, Geom::Coord const epsilon)
 
Point unit_vector (Point const &a)
 
Matrix without_translation (Matrix const &m)
 

Typedef Documentation

typedef double Geom::Coord

A "real" type with sufficient precision for coordinates.

You may safely assume that double (or even float) provides enough precision for storing on-canvas points, and hence that double provides enough precision for dot products of differences of on-canvas points.

Enumeration Type Documentation

enum Geom::Dim2
Enumerator

Function Documentation

Point Geom::abs ( Point const &  b)
double Geom::angle_between ( Point const  a,
Point const  b 
)

compute the angle turning from a to b (signed).

void Geom::assert_close ( Matrix const &  a,
Matrix const &  b 
)
double Geom::atan2 ( Point const  p)
int Geom::bezier_fit_cubic ( Point  bezier[],
Point const  data[],
int  len,
double  error 
)
int Geom::bezier_fit_cubic_full ( Point  bezier[],
int  split_points[],
Point const  data[],
int  len,
Point const &  tHat1,
Point const &  tHat2,
double  error,
unsigned  max_beziers 
)
int Geom::bezier_fit_cubic_r ( Point  bezier[],
Point const  data[],
int  len,
double  error,
unsigned  max_beziers 
)
Point Geom::bezier_pt ( unsigned  degree,
Point const  V[],
double  t 
)
Coord Geom::cross ( Point const &  a,
Point const &  b 
)

Defined as dot(a, b.cw()).

template<typename iterator >
static void Geom::cubic_bezier_poly_coeff ( iterator  b,
Point pc 
)
static
Point Geom::darray_left_tangent ( Point const  d[],
unsigned const  len 
)
Point Geom::darray_left_tangent ( Point const  d[],
unsigned const  len,
double const  tolerance_sq 
)
Point Geom::darray_right_tangent ( Point const  d[],
unsigned const  length,
double const  tolerance_sq 
)
Coord Geom::dist_sq ( Point const &  a,
Point const &  b 
)

compute the square of the distance between points a and b.

Coord Geom::distance ( Point const &  a,
Point const &  b 
)

compute the euclidean distance between points a and b.

XXX: hypot safer/faster?

Coord Geom::dot ( Point const &  a,
Point const &  b 
)

compute the dot product (inner product) between the vectors a and b.

Matrix Geom::elliptic_quadratic_form ( Matrix const &  m)

Given a matrix m such that unit_circle = m*x, this returns the quadratic form x*A*x = 1.

double Geom::expansion ( Matrix const &  m)
Matrix Geom::from_basis ( const Point  x_basis,
const Point  y_basis,
const Point  offset = Point(0, 0) 
)
Matrix Geom::identity ( )
bool Geom::is_unit_vector ( Point const &  p)
bool Geom::is_zero ( Point const &  p)
Coord Geom::L1 ( Point const &  p)
Coord Geom::L2 ( Point const &  p)

Compute the L2, or euclidean, norm of p.

Coord Geom::L2sq ( Point const &  p)

Compute the square of L2 norm of p.

Warning: this can overflow where L2 won't.

Point Geom::Lerp ( double const  t,
Point const  a,
Point const  b 
)

Given two points and a parameter t [0, 1], return a point proportionally from a to b by t.

Akin to 1 degree bezier.

double Geom::LInfty ( Point const &  p)
bool Geom::matrix_equalp ( Matrix const &  m0,
Matrix const &  m1,
Geom::Coord const  epsilon 
)
void Geom::matrix_print ( const char *  say,
Matrix const &  m 
)
bool Geom::operator!= ( Matrix const &  a,
Matrix const &  b 
)
bool Geom::operator!= ( Point const &  a,
Point const &  b 
)
Matrix Geom::operator* ( Scale const &  s,
Translate const &  t 
)
Matrix Geom::operator* ( Scale const &  s,
Matrix const &  m 
)
Point Geom::operator* ( Point const &  v,
Translate const &  t 
)
Matrix Geom::operator* ( Rotate const &  a,
Matrix const &  b 
)
Translate Geom::operator* ( Translate const &  a,
Translate const &  b 
)
Matrix Geom::operator* ( Translate const &  t,
Scale const &  s 
)
Matrix Geom::operator* ( Translate const &  t,
Rotate const &  r 
)
Point Geom::operator* ( Point const &  p,
Scale const &  s 
)
Matrix Geom::operator* ( Translate const &  t,
Matrix const &  m 
)
Scale Geom::operator* ( Scale const &  a,
Scale const &  b 
)
Matrix Geom::operator* ( Matrix const &  m,
Translate const &  t 
)
Matrix Geom::operator* ( Matrix const &  m,
Scale const &  s 
)
Matrix Geom::operator* ( Matrix const &  m,
Rotate const &  r 
)
Point Geom::operator* ( Point const &  v,
Rotate const &  r 
)
Rotate Geom::operator* ( Rotate const &  a,
Rotate const &  b 
)
Point Geom::operator* ( double const  s,
Point const &  p 
)
Point Geom::operator* ( Point const &  p,
double const  s 
)
Matrix Geom::operator* ( Matrix const &  a,
Matrix const &  b 
)
Point Geom::operator* ( Point const &  v,
Matrix const &  m 
)
Point Geom::operator+ ( Point const &  a,
Point const &  b 
)
Point Geom::operator- ( Point const &  a,
Point const &  b 
)
Point Geom::operator- ( Point const &  a)
Point Geom::operator/ ( Point const &  v,
Translate const &  t 
)
Translate Geom::operator/ ( Translate const &  a,
Translate const &  b 
)
Matrix Geom::operator/ ( Translate const &  t,
Scale const &  s 
)
Matrix Geom::operator/ ( Translate const &  t,
Rotate const &  r 
)
Point Geom::operator/ ( Point const &  p,
Scale const &  s 
)
Scale Geom::operator/ ( Scale const &  a,
Scale const &  b 
)
Matrix Geom::operator/ ( Matrix const &  m,
Scale const &  s 
)
Matrix Geom::operator/ ( Matrix const &  a,
Matrix const &  b 
)
Point Geom::operator/ ( Point const &  v,
Rotate const &  r 
)
Rotate Geom::operator/ ( Rotate const &  a,
Rotate const &  b 
)
Point Geom::operator/ ( Point const &  p,
double const  s 
)
Point Geom::operator/ ( double const  s,
Point const &  p 
)
Point Geom::operator/ ( Point const &  p,
Matrix const &  m 
)
std::ostream& Geom::operator<< ( std::ostream &  out_file,
const Geom::Point in_pnt 
)

A function to print out the Point.

It just prints out the coords on the given output stream

std::ostream& Geom::operator<< ( std::ostream &  out_file,
const Geom::Matrix m 
)

A function to print out the Matrix (for debugging)

bool Geom::operator<= ( Point const &  a,
Point const &  b 
)

This is a lexicographical ordering for points.

It is remarkably useful for sweepline algorithms

bool Geom::operator== ( Matrix const &  a,
Matrix const &  b 
)
bool Geom::operator== ( Point const &  a,
Point const &  b 
)
Point Geom::operator^ ( Point const &  a,
Point const &  b 
)

This is a rotation (sort of).

bool Geom::point_equalp ( Point const &  a,
Point const &  b,
double const  eps 
)
Point Geom::rot90 ( Point const &  p)

Returns p * Geom::rotate_degrees(90), but more efficient.

Angle direction in Inkscape code: If you use the traditional mathematics convention that y increases upwards, then positive angles are anticlockwise as per the mathematics convention. If you take the common non-mathematical convention that y increases downwards, then positive angles are clockwise, as is common outside of mathematics.

There is no rot_neg90 function: use -rot90(p) instead.

bool Geom::rotate_equalp ( Geom::Rotate const &  a,
Geom::Rotate const &  b,
double const  eps 
)
Translate Geom::to_translate ( Matrix const &  m)
bool Geom::transform_equalp ( Matrix const &  m0,
Matrix const &  m1,
Geom::Coord const  epsilon 
)
bool Geom::translate_equalp ( Matrix const &  m0,
Matrix const &  m1,
Geom::Coord const  epsilon 
)
Point Geom::unit_vector ( Point const &  a)
Matrix Geom::without_translation ( Matrix const &  m)