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 >:
Descriptive interface | |
typedef double | value_type |
static int | dim () |
Public Member Functions | |
Constructors | |
Vec2 () | |
Vec2 (double x, double y) | |
Overloaded Mathematical Operators | |
V | operator+ (const V &v) const |
V | operator- (const V &v) const |
double | operator * (const V &v) const |
V | operator- () const |
V | operator * (double s) const |
V | 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 | |
V | normalized () const |
Returns a unit-length copy of this vector. | |
V | 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). | |
V | projected (const V &b) const |
Returns the projection of this onto b. | |
V | 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. | |
V | 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. |
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.
|
|
|
|
|
|
|
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(). |
|
|
|
|
|
Definition at line 108 of file vec2.H. Referenced by mlib::Vec2< VEXEL >::is_equal(). |
|
|
|
|
|
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(). |
|
Definition at line 193 of file vec2.H. References mlib::epsNorSqrdMath(), and mlib::Vec2< V >::normalized(). |
|
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(). |
|
Definition at line 82 of file vec2.H. Referenced by mlib::Vec2< VEXEL >::is_null(), Bedge::nearest_pt_ndc(), and Patch::update_dynamic_samples(). |
|
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(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns this vector minus its projection onto b.
|
|
Returns a copy of the vector rotated 90 degrees CCW.
Definition at line 100 of file vec2.H. Referenced by ELLIPSE::set(). |
|
Returns the projection of this onto b.
Definition at line 131 of file vec2.H. Referenced by mlib::Vec2< VEXEL >::orthogonalized(). |
|
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(). |
|
Return (this * b) / (b * b).
Definition at line 125 of file vec2.H. Referenced by mlib::Vec2< VEXEL >::projected(). |
|
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(). |
|
Finds the angle between the two (undirected) lines defined by the given vectors. The result is between 0 and pi/2 radians.
|
|
double by Vec2 multiplication.
|
|
Stream insertion operator for Vec2 class.
|
|
|