27 #ifndef MESQUITE_VECTOR3D_HPP
28 #define MESQUITE_VECTOR3D_HPP
32 #ifdef MSQ_USE_OLD_IO_HEADERS
38 #ifdef MSQ_USE_OLD_C_HEADERS
69 Vector3D(
const double&
x,
const double&
y,
const double&
z);
85 void x(
const double x);
86 void y(
const double y);
87 void z(
const double z);
88 void set(
const double x,
const double y,
const double z);
89 void set(
const double xyz[3]);
110 const double scalar);
114 const double scalar);
119 friend double operator%(
const double scalar,
122 const double scalar);
139 double tolerance)
const;
147 inline double length()
const;
151 inline void set_length(
const double new_length);
186 { msq_stdc::memcpy(
mCoords, xyz, 3*
sizeof(
double)); }
204 { msq_stdc::memcpy(xyz,
mCoords, 3*
sizeof(
double)); }
226 { msq_stdc::memcpy(
mCoords, xyz, 3*
sizeof(
double)); }
271 double new_coords[3] =
276 msq_stdc::memcpy(
mCoords, new_coords, 3*
sizeof(
double));
326 assert (scalar != 0);
346 dot+= lhs[i].mCoords[0] * rhs[i].mCoords[0] +
347 lhs[i].mCoords[1] * rhs[i].mCoords[1] +
348 lhs[i].mCoords[2] * rhs[i].mCoords[2];
380 double tolerance)
const
382 return ((msq_stdc::fabs(this->
mCoords[0] - compare_to.
mCoords[0]) < tolerance) &&
383 (msq_stdc::fabs(this->mCoords[1] - compare_to.
mCoords[1]) < tolerance) &&
384 (msq_stdc::fabs(this->mCoords[2] - compare_to.
mCoords[2]) < tolerance));
403 for (
int j=0;
j<
n; ++
j)
404 l += v[
j].mCoords[0]*v[
j].mCoords[0] +
405 v[
j].mCoords[1]*v[
j].mCoords[1] +
406 v[
j].mCoords[2]*v[
j].mCoords[2];
413 for(
int i=0;
i<
n;++
i){
414 if ( max < msq_stdc::fabs(v[
i][0]) ) max=msq_stdc::fabs(v[i][0]) ;
415 if ( max < msq_stdc::fabs(v[i][1]) ) max=msq_stdc::fabs(v[i][1]) ;
416 if ( max < msq_stdc::fabs(v[i][2]) ) max=msq_stdc::fabs(v[i][2]) ;
423 double factor = new_length /
length();
434 return (1-param)*p1 + param*p2;
Vector3D & operator=(const Vector3D &to_copy)
friend const Vector3D operator+(const Vector3D &lhs, const Vector3D &rhs)
static double interior_angle(const Vector3D &a, const Vector3D &b, MsqError &err)
friend bool operator==(const Vector3D &lhs, const Vector3D &rhs)
const Matrix3D operator*(const Matrix3D &A, const Matrix3D &B)
friend double inner(const Vector3D v1[], const Vector3D v2[], int n)
dot product for array
bool operator!=(const Matrix3D &lhs, const Matrix3D &rhs)
void int int REAL REAL * y
Used to hold the error state and return it to the application.
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
friend void eqAx(Vector3D &v, const Matrix3D &A, const Vector3D &x)
const double & operator[](size_t index) const
Vector3D & operator/=(const double scalar)
divides each Vector3D entry by the given scalar.
friend const Vector3D operator*(const Vector3D &lhs, const double scalar)
lhs * scalar
friend double Linf(Vector3D *const v, int n)
L inf norm for array of Vector3Ds.
double length(Vector3D *const v, int n)
friend void plusEqTransAx(Vector3D &v, const Matrix3D &A, const Vector3D &x)
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
friend double operator%(const Vector3D &v1, const Vector3D &v2)
dot product
NVec< 3, double > Vector3D
void get_coordinates(double &x, double &y, double &z) const
void int int int REAL REAL REAL * z
3*3 Matric class, row-oriented, 0-based [i][j] indexing.
bool operator==(const Matrix3D &lhs, const Matrix3D &rhs)
const Matrix3D operator-(const Matrix3D &A, const Matrix3D &B)
static double distance_between(const Vector3D &p1, const Vector3D &p2)
Vector3D & operator*=(const double scalar)
int within_tolerance_box(const Vector3D &compare_to, double tolerance) const
Vector3D & operator+=(const Vector3D &rhs)
Vector3D & operator-=(const Vector3D &rhs)
double Linf(Vector3D *const v, int n)
friend void plusEqAx(Vector3D &v, const Matrix3D &A, const Vector3D &x)
const Matrix3D operator+(const Matrix3D &A, const Matrix3D &B)
void set_length(const double new_length)
double length_squared() const
static Vector3D interpolate(const double param, const Vector3D &p1, const Vector3D &p2)
const double * to_array() const
msq_stdio::ostream & operator<<(msq_stdio::ostream &s, const Matrix3D &A)
void set(const double x, const double y, const double z)
friend const Vector3D operator/(const Vector3D &lhs, const double scalar)
friend bool operator!=(const Vector3D &lhs, const Vector3D &rhs)
double inner(const Vector3D lhs[], const Vector3D rhs[], int n)
double operator%(const Vector3D &lhs, const Vector3D &rhs)
const Vector3D operator/(const Vector3D &lhs, const double scalar)
Vector3D operator-() const