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 >:
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 | |
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) |
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). | |
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 |
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 | |
V | normalized () const |
Return a unit-length copy of this vector. | |
V | 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. | |
V | operator * (double s, const Vec3< V > &v) |
double by Vec3 multiplication. | |
V | 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. |
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.
|
|
|
Default constructor. Creates a zero length vector.
|
|
Constructor that sets the components of the vector to the values specified in the arguments.
|
|
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(). |
|
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(). |
|
|
|
Compute the distance between the two vectors.
Definition at line 120 of file vec3.H. Referenced by GEOM::do_cam_focus(). |
|
Compute the distance squared between the two vectors.
Definition at line 122 of file vec3.H. Referenced by mlib::Vec3< Wvec >::is_equal(). |
|
Are the two vectors equal?
|
|
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(). |
|
Are the two vectors parallel?
Definition at line 225 of file vec3.H. References mlib::epsNorSqrdMath(), and mlib::Vec3< V >::normalized(). |
|
Are the two vectors perpendicular?
Definition at line 244 of file vec3.H. References mlib::epsNorMath(), and mlib::Vec3< V >::normalized(). |
|
|
|
|
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(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Provided so that min(V, V) and max(V, V) work.
|
|
|
|
Provided so that min(V, V) and max(V, V) work.
|
|
|
|
|
|
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(). |
|
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(). |
|
Returns the projection of this onto b.
Definition at line 135 of file vec3.H. Referenced by mlib::Vec3< Wvec >::orthogonalized(). |
|
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(). |
|
Returns (this * b) / (b * b).
Definition at line 129 of file vec3.H. Referenced by mlib::Vec3< Wvec >::projected(). |
|
Computes the cross product of two Vec3's.
Definition at line 307 of file vec3.H. Referenced by mlib::Vec3< V >::perpend(). |
|
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(). |
|
double by Vec3 multiplication.
|
|
Stream insertion operator for Vec3 class.
|
|
Stream extraction operator for Vec3 class.
Definition at line 287 of file vec3.H. References dummy. |
|
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(). |
|
|
|