Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

mlib::Vec2< V > Class Template Reference
[MLIB]

A 2D vector class with double precision floating point elements.

This class is designed to be base class of more specific types of 2D vectors. Specifically, 2D vectors in different coordinate systems. The template argument V is the type of the derived vector class. This allows the Vec2 to return new vectors of the same type as the derived class. More...

#include <vec2.H>

Inheritance diagram for mlib::Vec2< V >:

Inheritance graph
[legend]
List of all members.

Descriptive interface

typedef double value_type
static int dim ()

Public Member Functions

Constructors
 Vec2 ()
 Vec2 (double x, double y)
Overloaded Mathematical Operators
operator+ (const V &v) const
operator- (const V &v) const
double operator * (const V &v) const
operator- () const
operator * (double s) const
operator/ (double s) const
void operator+= (const V &v)
void operator-= (const V &v)
void operator *= (double s)
void operator/= (double s)
Element Access Functions
double operator[] (int index) const
double & operator[] (int index)
Vector Property Queries
double length () const
double length_sqrd () const
bool is_exact_null () const
bool is_null (double epsSqrdMath=epsNorSqrdMath()) const
 Tells if the vector is basically the zero vector.
Single Vector Operations
normalized () const
 Returns a unit-length copy of this vector.
perpend () const
 Returns a copy of the vector rotated 90 degrees CCW.
Two Vector Operations
double dist (const V &v) const
double dist_sqrd (const V &v) const
double signed_angle (const V &) const
 Returns the signed angle between this vector and the given one.
double angle (const V &v) const
 Returns the unsigned angle between the two vectors. The result will lie between 0 and pi radians.
double tlen (const V &b) const
 Return (this * b) / (b * b).
projected (const V &b) const
 Returns the projection of this onto b.
orthogonalized (const V &b) const
 Returns this vector minus its projection onto b.
Vector Comparison Functions
bool is_equal (const V &v, double epsSqrd=epsNorSqrdMath()) const
bool is_parallel (const V &) const
Overloaded Comparison Operators
bool operator== (const V &v) const
bool operator!= (const V &v) const

Protected Attributes

double _x
double _y

Related Functions

(Note that these are not member functions.)

double det (const Vec2< V > &v1, const Vec2< V > &v2)
 Returns the 'z' coordinate of the cross product of the two vectors.
ostream & operator<< (ostream &os, const Vec2< V > &v)
 Stream insertion operator for Vec2 class.
operator * (double s, const Vec2< V > &v)
 double by Vec2 multiplication.
double line_angle (const V &v1, const V &v2)
 Finds the angle between the two (undirected) lines defined by the given vectors. The result is between 0 and pi/2 radians.

Detailed Description

template<class V>
class mlib::Vec2< V >

A 2D vector class with double precision floating point elements.

This class is designed to be base class of more specific types of 2D vectors. Specifically, 2D vectors in different coordinate systems. The template argument V is the type of the derived vector class. This allows the Vec2 to return new vectors of the same type as the derived class.

Definition at line 28 of file vec2.H.


Member Typedef Documentation

template<class V>
typedef double mlib::Vec2< V >::value_type
 

Definition at line 47 of file vec2.H.


Constructor & Destructor Documentation

template<class V>
mlib::Vec2< V >::Vec2  )  [inline]
 

Definition at line 39 of file vec2.H.

template<class V>
mlib::Vec2< V >::Vec2 double  x,
double  y
[inline]
 

Definition at line 40 of file vec2.H.


Member Function Documentation

template<class V>
double mlib::Vec2< V >::angle const V &  v  )  const [inline]
 

Returns the unsigned angle between the two vectors. The result will lie between 0 and pi radians.

Definition at line 184 of file vec2.H.

References mlib::Vec2< V >::signed_angle().

template<class V>
static int mlib::Vec2< V >::dim  )  [inline, static]
 

Definition at line 48 of file vec2.H.

template<class V>
double mlib::Vec2< V >::dist const V &  v  )  const [inline]
 

Definition at line 107 of file vec2.H.

template<class V>
double mlib::Vec2< V >::dist_sqrd const V &  v  )  const [inline]
 

Definition at line 108 of file vec2.H.

Referenced by mlib::Vec2< VEXEL >::is_equal().

template<class V>
bool mlib::Vec2< V >::is_equal const V &  v,
double  epsSqrd = epsNorSqrdMath()
const [inline]
 

Definition at line 141 of file vec2.H.

template<class V>
bool mlib::Vec2< V >::is_exact_null  )  const [inline]
 

Definition at line 84 of file vec2.H.

template<class V>
bool mlib::Vec2< V >::is_null double  epsSqrdMath = epsNorSqrdMath()  )  const [inline]
 

Tells if the vector is basically the zero vector.

Definition at line 87 of file vec2.H.

Referenced by GESTURE::is_ellipse(), and ELLIPSE::rebuild().

template<class V>
bool mlib::Vec2< V >::is_parallel const V &   )  const [inline]
 

Definition at line 193 of file vec2.H.

References mlib::epsNorSqrdMath(), and mlib::Vec2< V >::normalized().

template<class V>
double mlib::Vec2< V >::length  )  const [inline]
 

Definition at line 81 of file vec2.H.

Referenced by Cam_int::choose(), Cam_int_fp::choose(), Cam_int_edit::choose(), GESTURE::is_ellipse(), mlib::Vec2< V >::normalized(), and Patch::update_dynamic_samples().

template<class V>
double mlib::Vec2< V >::length_sqrd  )  const [inline]
 

Definition at line 82 of file vec2.H.

Referenced by mlib::Vec2< VEXEL >::is_null(), Bedge::nearest_pt_ndc(), and Patch::update_dynamic_samples().

template<class V>
V mlib::Vec2< V >::normalized  )  const [inline]
 

Returns a unit-length copy of this vector.

Definition at line 163 of file vec2.H.

References mlib::Vec2< V >::_x, mlib::Vec2< V >::_y, mlib::gEpsZeroMath, and mlib::Vec2< V >::length().

Referenced by GESTURE::is_e_line(), GESTURE::is_ellipse(), GESTURE::is_n_line(), GESTURE::is_ne_line(), GESTURE::is_nw_line(), mlib::Vec2< V >::is_parallel(), GESTURE::is_s_line(), GESTURE::is_se_line(), GESTURE::is_sw_line(), GESTURE::is_w_line(), ELLIPSE::set(), mlib::Vec2< V >::signed_angle(), Patch::update_dynamic_samples(), and GESTURE::vecn().

template<class V>
V mlib::Vec2< V >::operator * double  s  )  const [inline]
 

Definition at line 60 of file vec2.H.

template<class V>
double mlib::Vec2< V >::operator * const V &  v  )  const [inline]
 

Definition at line 57 of file vec2.H.

template<class V>
void mlib::Vec2< V >::operator *= double  s  )  [inline]
 

Definition at line 65 of file vec2.H.

template<class V>
bool mlib::Vec2< V >::operator!= const V &  v  )  const [inline]
 

Definition at line 151 of file vec2.H.

template<class V>
V mlib::Vec2< V >::operator+ const V &  v  )  const [inline]
 

Definition at line 55 of file vec2.H.

template<class V>
void mlib::Vec2< V >::operator+= const V &  v  )  [inline]
 

Definition at line 63 of file vec2.H.

template<class V>
V mlib::Vec2< V >::operator-  )  const [inline]
 

Definition at line 58 of file vec2.H.

template<class V>
V mlib::Vec2< V >::operator- const V &  v  )  const [inline]
 

Definition at line 56 of file vec2.H.

template<class V>
void mlib::Vec2< V >::operator-= const V &  v  )  [inline]
 

Definition at line 64 of file vec2.H.

template<class V>
V mlib::Vec2< V >::operator/ double  s  )  const [inline]
 

Definition at line 61 of file vec2.H.

template<class V>
void mlib::Vec2< V >::operator/= double  s  )  [inline]
 

Definition at line 66 of file vec2.H.

template<class V>
bool mlib::Vec2< V >::operator== const V &  v  )  const [inline]
 

Definition at line 150 of file vec2.H.

template<class V>
double& mlib::Vec2< V >::operator[] int  index  )  [inline]
 

Definition at line 74 of file vec2.H.

template<class V>
double mlib::Vec2< V >::operator[] int  index  )  const [inline]
 

Definition at line 73 of file vec2.H.

template<class V>
V mlib::Vec2< V >::orthogonalized const V &  b  )  const [inline]
 

Returns this vector minus its projection onto b.

Definition at line 134 of file vec2.H.

template<class V>
V mlib::Vec2< V >::perpend  )  const [inline]
 

Returns a copy of the vector rotated 90 degrees CCW.

Definition at line 100 of file vec2.H.

Referenced by ELLIPSE::set().

template<class V>
V mlib::Vec2< V >::projected const V &  b  )  const [inline]
 

Returns the projection of this onto b.

Definition at line 131 of file vec2.H.

Referenced by mlib::Vec2< VEXEL >::orthogonalized().

template<class V>
double mlib::Vec2< V >::signed_angle const V &   )  const [inline]
 

Returns the signed angle between this vector and the given one.

I.e., returns the angle by which to rotate this vector counter-clockwise to align with the given vector. The result will be negative if the smallest rotation to get to the given vector is in the clockwise direction. The result will lie between -pi and pi radians:

Definition at line 171 of file vec2.H.

References mlib::Acos(), mlib::Vec2< V >::det(), mlib::Vec2< V >::normalized(), and Sign().

Referenced by mlib::Vec2< V >::angle().

template<class V>
double mlib::Vec2< V >::tlen const V &  b  )  const [inline]
 

Return (this * b) / (b * b).

Definition at line 125 of file vec2.H.

Referenced by mlib::Vec2< VEXEL >::projected().


Friends And Related Function Documentation

template<class V>
double det const Vec2< V > &  v1,
const Vec2< V > &  v2
[related]
 

Returns the 'z' coordinate of the cross product of the two vectors.

Definition at line 214 of file vec2.H.

Referenced by mlib::Vec2< V >::signed_angle().

template<class V>
double line_angle const V &  v1,
const V &  v2
[related]
 

Finds the angle between the two (undirected) lines defined by the given vectors. The result is between 0 and pi/2 radians.

Note:
Because of how this is templated, it also works with 3D vectors (Vec3 class).

Definition at line 248 of file vec2.H.

template<class V>
V operator * double  s,
const Vec2< V > &  v
[related]
 

double by Vec2 multiplication.

Definition at line 234 of file vec2.H.

template<class V>
ostream & operator<< ostream &  os,
const Vec2< V > &  v
[related]
 

Stream insertion operator for Vec2 class.

Definition at line 225 of file vec2.H.


Member Data Documentation

template<class V>
double mlib::Vec2< V >::_x [protected]
 

Definition at line 32 of file vec2.H.

Referenced by mlib::Vec2< VEXEL >::is_exact_null(), mlib::Vec2< VEXEL >::length(), mlib::Vec2< VEXEL >::length_sqrd(), mlib::Vec2< V >::normalized(), mlib::Vec2< VEXEL >::operator *(), mlib::Vec2< VEXEL >::operator *=(), mlib::Vec2< VEXEL >::operator!=(), mlib::Vec2< VEXEL >::operator+(), mlib::Vec2< VEXEL >::operator+=(), mlib::Vec2< VEXEL >::operator-(), mlib::Vec2< VEXEL >::operator-=(), mlib::Vec2< VEXEL >::operator/(), mlib::Vec2< VEXEL >::operator/=(), mlib::Vec2< VEXEL >::operator==(), mlib::Vec2< VEXEL >::operator[](), and mlib::Vec2< VEXEL >::perpend().

template<class V>
double mlib::Vec2< V >::_y [protected]
 

Definition at line 32 of file vec2.H.

Referenced by mlib::Vec2< VEXEL >::is_exact_null(), mlib::Vec2< VEXEL >::length(), mlib::Vec2< VEXEL >::length_sqrd(), mlib::Vec2< V >::normalized(), mlib::Vec2< VEXEL >::operator *(), mlib::Vec2< VEXEL >::operator *=(), mlib::Vec2< VEXEL >::operator!=(), mlib::Vec2< VEXEL >::operator+(), mlib::Vec2< VEXEL >::operator+=(), mlib::Vec2< VEXEL >::operator-(), mlib::Vec2< VEXEL >::operator-=(), mlib::Vec2< VEXEL >::operator/(), mlib::Vec2< VEXEL >::operator/=(), mlib::Vec2< VEXEL >::operator==(), and mlib::Vec2< VEXEL >::perpend().


The documentation for this class was generated from the following file:
Generated on Mon Sep 18 11:48:25 2006 for jot by  doxygen 1.4.4