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

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

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

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

#include <vec3.H>

Inheritance diagram for mlib::Vec3< V >:

Inheritance graph
[legend]
List of all members.

Descriptive interface

typedef double value_type
static int dim ()

Public Member Functions

Constructors
 Vec3 ()
 Default constructor. Creates a zero length vector.
 Vec3 (double x, double y, double z)
 Constructor that sets the components of the vector to the values specified in the arguments.
Element Access Functions
const double * data () const
 Returns the elements of the vector as an array.
void set (double x, double y, double z)
 Sets the components of the vector to the values specified in the arguments.
double operator[] (int index) const
double & operator[] (int index)
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)
Overloaded Comparison Operators
int operator> (const V &v) const
int operator< (const V &v) const
bool operator== (const V &v) const
bool operator!= (const V &v) const
Vector Property Queries
double length () const
double length_sqrd () const
double length_rect () const
bool is_null (double epsSqrd=epsNorSqrdMath()) const
 Is the vector's length equal to zero?
Two Vector Operations
double dist (const V &v) const
 Compute the distance between the two vectors.
double dist_sqrd (const V &v) const
 Compute the distance squared between the two vectors.
double angle (const V &) const
 Compute the angle between the two vectors. The result will be in the range 0 to pi radians.
double tlen (const V &b) const
 Returns (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
 Are the two vectors equal?
bool is_parallel (const V &) const
 Are the two vectors parallel?
bool is_perpend (const V &) const
 Are the two vectors perpendicular?
Single Vector Operations
normalized () const
 Return a unit-length copy of this vector.
perpend () const
 Return a vector perpendicular to this one using an arbitrary axis algorithm.

Protected Attributes

double _x
double _y
double _z

Related Functions

(Note that these are not member functions.)

ostream & operator<< (ostream &os, const Vec3< V > &v)
 Stream insertion operator for Vec3 class.
istream & operator>> (istream &is, Vec3< V > &v)
 Stream extraction operator for Vec3 class.
operator * (double s, const Vec3< V > &v)
 double by Vec3 multiplication.
cross (const V &v1, const V &v2)
 Computes the cross product of two Vec3's.
double det (const V &a, const V &b, const V &c)
 Computes the scalar triple product of three Vec3's (or, equivalently, the determinant of the 3x3 matrix with the three Vec3's as rows).
double signed_angle (const V &v1, const V &v2, const V &n)
 Returns the angle between v1 and v2, negated if v1 x v2 points in the opposite direction from n.

Detailed Description

template<class V>
class mlib::Vec3< V >

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

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

Definition at line 27 of file vec3.H.


Member Typedef Documentation

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

Definition at line 49 of file vec3.H.


Constructor & Destructor Documentation

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

Default constructor. Creates a zero length vector.

Definition at line 39 of file vec3.H.

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

Constructor that sets the components of the vector to the values specified in the arguments.

Definition at line 42 of file vec3.H.


Member Function Documentation

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

Compute the angle between the two vectors. The result will be in the range 0 to pi radians.

Definition at line 257 of file vec3.H.

References mlib::Acos(), and mlib::Vec3< V >::normalized().

template<class V>
const double* mlib::Vec3< V >::data  )  const [inline]
 

Returns the elements of the vector as an array.

Definition at line 58 of file vec3.H.

Referenced by SHOW_TRIS::draw_flat_tri(), ToonTexCB::faceCB(), and ToonTexCB_1D::faceCB().

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

Definition at line 50 of file vec3.H.

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

Compute the distance between the two vectors.

Definition at line 120 of file vec3.H.

Referenced by GEOM::do_cam_focus().

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

Compute the distance squared between the two vectors.

Definition at line 122 of file vec3.H.

Referenced by mlib::Vec3< Wvec >::is_equal().

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

Are the two vectors equal?

Note:
Checks to see if the distance between the two vectors is less than or equal to epsSqrd.

Definition at line 148 of file vec3.H.

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

Is the vector's length equal to zero?

Definition at line 111 of file vec3.H.

Referenced by BMESH::compute_pix_size(), mlib::Wpt_list::get_best_fit_plane(), and Bvert::view_intersect().

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

Are the two vectors parallel?

Definition at line 225 of file vec3.H.

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

template<class V>
bool mlib::Vec3< V >::is_perpend const V &   )  const [inline]
 

Are the two vectors perpendicular?

Definition at line 244 of file vec3.H.

References mlib::epsNorMath(), and mlib::Vec3< V >::normalized().

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

Definition at line 106 of file vec3.H.

Referenced by QuadtreeNode::build_quadtree(), BMESH::compute_pix_size(), Cam_int_fp::cruise_zoom(), VertUVTexture::draw(), LMESH::fit(), fit(), Bedge::length(), mlib::Vec3< V >::normalized(), mlib::Vec3< Wvec >::operator<(), mlib::Vec3< Wvec >::operator>(), mlib::NDCZpt_list::segment_length(), StripTexCoordsCB2::send_d(), StripTexCoordsCB3::send_d(), sps(), CamCruise::tick(), TestSPSapp::toggle_sample_cb(), VIEW::viewall(), mlib::NDCZpt_list::xy_len(), Cam_int::zoom(), and Cam_int_edit::zoom().

template<class V>
double mlib::Vec3< V >::length_rect  )  const [inline]
 

Definition at line 108 of file vec3.H.

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

Definition at line 107 of file vec3.H.

Referenced by BMESHcurvature_data::compute_corner_areas(), mlib::Vec3< Wvec >::is_null(), and BBOX::is_off_screen().

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

Return a unit-length copy of this vector.

Definition at line 178 of file vec3.H.

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

Referenced by add_shading(), mlib::Vec3< V >::angle(), Bface_list::avg_normal(), Bface::bc2norm_blend(), compute_ntb_coord_sys(), GLSphirTexCoordGen::compute_uv(), Cam_int_fp::cruise_zoom(), GEOM::do_cam_focus(), VertUVTexture::draw(), VIEW::eye_vec(), Bvert::eye_vec(), ToonTexCB::faceCB(), ToonTexCB_1D::faceCB(), XToonStripCB::faceCB(), Cam_int_fp::focus(), mlib::Wpt_list::get_best_fit_plane(), Light::get_direction(), ZcrossPath::has_sil(), mlib::NDCZpt_list::interpolate(), BMESH::intersect(), mlib::Vec3< V >::is_parallel(), mlib::Vec3< V >::is_perpend(), project(), Bface::quad_norm(), Bface::quad_tan1(), Bface::quad_tan2(), StripTexCoordsCB2::send_d(), StripTexCoordsCB3::send_d(), SimplexFrame::set_(), Bvert::set_norm(), Bface::set_normal(), Bedge::swapable(), CamCruise::tick(), XToonTexture::update_lights(), ToonTexture_1D::update_lights(), vert_normal(), Bface::vert_normal(), Bvert::view_intersect(), Bface::view_intersect(), Bedge::view_intersect(), Cam_int::zoom(), and Cam_int_edit::zoom().

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

Definition at line 76 of file vec3.H.

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

Definition at line 74 of file vec3.H.

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

Definition at line 81 of file vec3.H.

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

Definition at line 99 of file vec3.H.

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

Definition at line 72 of file vec3.H.

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

Definition at line 79 of file vec3.H.

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

Definition at line 75 of file vec3.H.

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

Definition at line 73 of file vec3.H.

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

Definition at line 80 of file vec3.H.

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

Definition at line 77 of file vec3.H.

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

Definition at line 82 of file vec3.H.

template<class V>
int mlib::Vec3< V >::operator< const V &  v  )  const [inline]
 

Provided so that min(V, V) and max(V, V) work.

Note:
Comparison is done by length (not by comparing individual components).

Definition at line 96 of file vec3.H.

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

Definition at line 98 of file vec3.H.

template<class V>
int mlib::Vec3< V >::operator> const V &  v  )  const [inline]
 

Provided so that min(V, V) and max(V, V) work.

Note:
Comparison is done by length (not by comparing individual components).

Definition at line 92 of file vec3.H.

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

Definition at line 65 of file vec3.H.

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

Definition at line 64 of file vec3.H.

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

Returns this vector minus its projection onto b.

Definition at line 138 of file vec3.H.

Referenced by Bface::quad_tan1(), Bface::quad_tan2(), SimplexFrame::set_(), ZcrossPath::sil_walk_search(), and ZcrossPath::start_sil().

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

Return a vector perpendicular to this one using an arbitrary axis algorithm.

The arbitrary perpendicular vector is found as follows. First, the minimum length component of the vector is found. Second, a new vector is created that is the unit vector along the direction of the minimum component. Third, the perpendicular vector is found by taking the cross product of the vector with the minimum component set to zero and the original vector. Fourth, the perpendicular vector is normalized.

Definition at line 195 of file vec3.H.

References mlib::Vec3< V >::cross().

Referenced by Bedge::norm(), and LINE3D::normal().

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

Returns the projection of this onto b.

Definition at line 135 of file vec3.H.

Referenced by mlib::Vec3< Wvec >::orthogonalized().

template<class V>
void mlib::Vec3< V >::set double  x,
double  y,
double  z
[inline]
 

Sets the components of the vector to the values specified in the arguments.

Definition at line 62 of file vec3.H.

Referenced by Bsimplex::clamp_barycentric(), Bface::nearest_pt(), Bface::nearest_pt_ndc(), Bedge::nearest_pt_ndc(), Bvert::project_barycentric(), Bface::project_barycentric(), Bedge::project_barycentric(), and Bface::project_barycentric_ndc().

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

Returns (this * b) / (b * b).

Definition at line 129 of file vec3.H.

Referenced by mlib::Vec3< Wvec >::projected().


Friends And Related Function Documentation

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

Computes the cross product of two Vec3's.

Definition at line 307 of file vec3.H.

Referenced by mlib::Vec3< V >::perpend().

template<class V>
double det const V &  a,
const V &  b,
const V &  c
[related]
 

Computes the scalar triple product of three Vec3's (or, equivalently, the determinant of the 3x3 matrix with the three Vec3's as rows).

Definition at line 320 of file vec3.H.

References mlib::cross().

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

double by Vec3 multiplication.

Definition at line 297 of file vec3.H.

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

Stream insertion operator for Vec3 class.

Definition at line 277 of file vec3.H.

template<class V>
istream & operator>> istream &  is,
Vec3< V > &  v
[related]
 

Stream extraction operator for Vec3 class.

Definition at line 287 of file vec3.H.

References dummy.

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

Returns the angle between v1 and v2, negated if v1 x v2 points in the opposite direction from n.

Definition at line 330 of file vec3.H.

References Sign().


Member Data Documentation

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

Definition at line 31 of file vec3.H.

Referenced by mlib::Vec3< Wvec >::data(), mlib::Vec3< Wvec >::length(), mlib::Vec3< Wvec >::length_rect(), mlib::Vec3< Wvec >::length_sqrd(), mlib::Vec3< V >::normalized(), mlib::Vec3< Wvec >::operator *(), mlib::Vec3< Wvec >::operator *=(), mlib::Vec3< Wvec >::operator!=(), mlib::Vec3< Wvec >::operator+(), mlib::Vec3< Wvec >::operator+=(), mlib::Vec3< Wvec >::operator-(), mlib::Vec3< Wvec >::operator-=(), mlib::Vec3< Wvec >::operator/(), mlib::Vec3< Wvec >::operator/=(), mlib::Vec3< Wvec >::operator==(), mlib::Vec3< Wvec >::operator[](), and mlib::Vec3< Wvec >::set().

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

Definition at line 31 of file vec3.H.

Referenced by mlib::Vec3< Wvec >::length(), mlib::Vec3< Wvec >::length_rect(), mlib::Vec3< Wvec >::length_sqrd(), mlib::Vec3< V >::normalized(), mlib::Vec3< Wvec >::operator *(), mlib::Vec3< Wvec >::operator *=(), mlib::Vec3< Wvec >::operator!=(), mlib::Vec3< Wvec >::operator+(), mlib::Vec3< Wvec >::operator+=(), mlib::Vec3< Wvec >::operator-(), mlib::Vec3< Wvec >::operator-=(), mlib::Vec3< Wvec >::operator/(), mlib::Vec3< Wvec >::operator/=(), mlib::Vec3< Wvec >::operator==(), and mlib::Vec3< Wvec >::set().

template<class V>
double mlib::Vec3< V >::_z [protected]
 

Definition at line 31 of file vec3.H.

Referenced by mlib::Vec3< Wvec >::length(), mlib::Vec3< Wvec >::length_rect(), mlib::Vec3< Wvec >::length_sqrd(), mlib::Vec3< V >::normalized(), mlib::Vec3< Wvec >::operator *(), mlib::Vec3< Wvec >::operator *=(), mlib::Vec3< Wvec >::operator!=(), mlib::Vec3< Wvec >::operator+(), mlib::Vec3< Wvec >::operator+=(), mlib::Vec3< Wvec >::operator-(), mlib::Vec3< Wvec >::operator-=(), mlib::Vec3< Wvec >::operator/(), mlib::Vec3< Wvec >::operator/=(), mlib::Vec3< Wvec >::operator==(), and mlib::Vec3< Wvec >::set().


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