Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/linmath/lvecBase4_src.I

Go to the documentation of this file.
00001 // Filename: lvecBase4_src.I
00002 // Created by:  drose (08Mar00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: LVecBase4::Default Constructor
00022 //       Access: Public
00023 //  Description:
00024 ////////////////////////////////////////////////////////////////////
00025 INLINE_LINMATH FLOATNAME(LVecBase4)::
00026 FLOATNAME(LVecBase4)() {
00027 }
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: LVecBase4::Copy Constructor
00031 //       Access: Public
00032 //  Description:
00033 ////////////////////////////////////////////////////////////////////
00034 INLINE_LINMATH FLOATNAME(LVecBase4)::
00035 FLOATNAME(LVecBase4)(const FLOATNAME(LVecBase4) &copy) {
00036   _v.v._0 = copy._v.v._0;
00037   _v.v._1 = copy._v.v._1;
00038   _v.v._2 = copy._v.v._2;
00039   _v.v._3 = copy._v.v._3;
00040 //  (*this) = copy;
00041 }
00042 
00043 ////////////////////////////////////////////////////////////////////
00044 //     Function: LVecBase4::Copy Assignment Operator
00045 //       Access: Public
00046 //  Description:
00047 ////////////////////////////////////////////////////////////////////
00048 INLINE_LINMATH FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4)::
00049 operator = (const FLOATNAME(LVecBase4) &copy) {
00050   _v.v._0 = copy._v.v._0;
00051   _v.v._1 = copy._v.v._1;
00052   _v.v._2 = copy._v.v._2;
00053   _v.v._3 = copy._v.v._3;
00054 //  set(copy[0], copy[1], copy[2], copy[3]);
00055   return *this;
00056 }
00057 
00058 ////////////////////////////////////////////////////////////////////
00059 //     Function: LVecBase4::Fill Assignment Operator
00060 //       Access: Public
00061 //  Description:
00062 ////////////////////////////////////////////////////////////////////
00063 INLINE_LINMATH FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4)::
00064 operator = (FLOATTYPE fill_value) {
00065   fill(fill_value);
00066   return *this;
00067 }
00068 
00069 ////////////////////////////////////////////////////////////////////
00070 //     Function: LVecBase4::Constructor
00071 //       Access: Public
00072 //  Description:
00073 ////////////////////////////////////////////////////////////////////
00074 INLINE_LINMATH FLOATNAME(LVecBase4)::
00075 FLOATNAME(LVecBase4)(FLOATTYPE fill_value) {
00076   fill(fill_value);
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //     Function: LVecBase4::Constructor
00081 //       Access: Public
00082 //  Description:
00083 ////////////////////////////////////////////////////////////////////
00084 INLINE_LINMATH FLOATNAME(LVecBase4)::
00085 FLOATNAME(LVecBase4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) {
00086   _v.v._0 = x;
00087   _v.v._1 = y;
00088   _v.v._2 = z;
00089   _v.v._3 = w;
00090 //  set(x, y, z, w);
00091 }
00092 
00093 ////////////////////////////////////////////////////////////////////
00094 //     Function: LVecBase4::Destructor
00095 //       Access: Public
00096 //  Description:
00097 ////////////////////////////////////////////////////////////////////
00098 INLINE_LINMATH FLOATNAME(LVecBase4)::
00099 ~FLOATNAME(LVecBase4)() {
00100 }
00101 
00102 ////////////////////////////////////////////////////////////////////
00103 //     Function: LVecBase4::zero Named Constructor
00104 //       Access: Public
00105 //  Description: Returns a zero-length vector.
00106 ////////////////////////////////////////////////////////////////////
00107 INLINE_LINMATH const FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4)::
00108 zero() {
00109   return _zero;
00110 }
00111 
00112 ////////////////////////////////////////////////////////////////////
00113 //     Function: LVecBase4::unit_x Named Constructor
00114 //       Access: Public
00115 //  Description: Returns a unit X vector.
00116 ////////////////////////////////////////////////////////////////////
00117 INLINE_LINMATH const FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4)::
00118 unit_x() {
00119   return _unit_x;
00120 }
00121 
00122 ////////////////////////////////////////////////////////////////////
00123 //     Function: LVecBase4::unit_y Named Constructor
00124 //       Access: Public
00125 //  Description: Returns a unit Y vector.
00126 ////////////////////////////////////////////////////////////////////
00127 INLINE_LINMATH const FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4)::
00128 unit_y() {
00129   return _unit_y;
00130 }
00131 
00132 ////////////////////////////////////////////////////////////////////
00133 //     Function: LVecBase4::unit_z Named Constructor
00134 //       Access: Public
00135 //  Description: Returns a unit Z vector.
00136 ////////////////////////////////////////////////////////////////////
00137 INLINE_LINMATH const FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4)::
00138 unit_z() {
00139   return _unit_z;
00140 }
00141 
00142 ////////////////////////////////////////////////////////////////////
00143 //     Function: LVecBase4::unit_w Named Constructor
00144 //       Access: Public
00145 //  Description: Returns a unit W vector.
00146 ////////////////////////////////////////////////////////////////////
00147 INLINE_LINMATH const FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4)::
00148 unit_w() {
00149   return _unit_w;
00150 }
00151 
00152 ////////////////////////////////////////////////////////////////////
00153 //     Function: LVecBase4::Indexing Operator
00154 //       Access: Public
00155 //  Description:
00156 ////////////////////////////////////////////////////////////////////
00157 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
00158 operator [](int i) const {
00159   nassertr(i >= 0 && i < 4, 0.0);
00160   return _v.data[i];
00161 }
00162 
00163 ////////////////////////////////////////////////////////////////////
00164 //     Function: LVecBase4::Indexing Operator
00165 //       Access: Public
00166 //  Description:
00167 ////////////////////////////////////////////////////////////////////
00168 INLINE_LINMATH FLOATTYPE &FLOATNAME(LVecBase4)::
00169 operator [](int i) {
00170   nassertr(i >= 0 && i < 4, _v.data[0]);
00171   return _v.data[i];
00172 }
00173 
00174 ////////////////////////////////////////////////////////////////////
00175 //     Function: LVecBase4::is_nan
00176 //       Access: Public
00177 //  Description: Returns true if any component of the vector is
00178 //               not-a-number, false otherwise.
00179 ////////////////////////////////////////////////////////////////////
00180 INLINE_LINMATH bool FLOATNAME(LVecBase4)::
00181 is_nan() const {
00182   return cnan(_v.v._0) || cnan(_v.v._1) || cnan(_v.v._2) || cnan(_v.v._3);
00183 }
00184 
00185 ////////////////////////////////////////////////////////////////////
00186 //     Function: LVecBase4::get_cell
00187 //       Access: Public
00188 //  Description:
00189 ////////////////////////////////////////////////////////////////////
00190 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
00191 get_cell(int i) const {
00192   nassertr(i >= 0 && i < 4, 0.0);
00193   return _v.data[i];
00194 }
00195 
00196 ////////////////////////////////////////////////////////////////////
00197 //     Function: LVecBase4::get_x
00198 //       Access: Public
00199 //  Description:
00200 ////////////////////////////////////////////////////////////////////
00201 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
00202 get_x() const {
00203   return _v.v._0;
00204 }
00205 
00206 ////////////////////////////////////////////////////////////////////
00207 //     Function: LVecBase4::get_y
00208 //       Access: Public
00209 //  Description:
00210 ////////////////////////////////////////////////////////////////////
00211 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
00212 get_y() const {
00213   return _v.v._1;
00214 }
00215 
00216 ////////////////////////////////////////////////////////////////////
00217 //     Function: LVecBase4::get_z
00218 //       Access: Public
00219 //  Description:
00220 ////////////////////////////////////////////////////////////////////
00221 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
00222 get_z() const {
00223   return _v.v._2;
00224 }
00225 
00226 ////////////////////////////////////////////////////////////////////
00227 //     Function: LVecBase4::get_w
00228 //       Access: Public
00229 //  Description:
00230 ////////////////////////////////////////////////////////////////////
00231 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
00232 get_w() const {
00233   return _v.v._3;
00234 }
00235 
00236 ////////////////////////////////////////////////////////////////////
00237 //     Function: LVecBase4::set_cell
00238 //       Access: Public
00239 //  Description:
00240 ////////////////////////////////////////////////////////////////////
00241 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00242 set_cell(int i, FLOATTYPE value) {
00243   nassertv(i >= 0 && i < 4);
00244   _v.data[i] = value;
00245 }
00246 
00247 ////////////////////////////////////////////////////////////////////
00248 //     Function: LVecBase4::set_x
00249 //       Access: Public
00250 //  Description:
00251 ////////////////////////////////////////////////////////////////////
00252 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00253 set_x(FLOATTYPE value) {
00254   _v.v._0 = value;
00255 }
00256 
00257 ////////////////////////////////////////////////////////////////////
00258 //     Function: LVecBase4::set_y
00259 //       Access: Public
00260 //  Description:
00261 ////////////////////////////////////////////////////////////////////
00262 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00263 set_y(FLOATTYPE value) {
00264   _v.v._1 = value;
00265 }
00266 
00267 ////////////////////////////////////////////////////////////////////
00268 //     Function: LVecBase4::set_z
00269 //       Access: Public
00270 //  Description:
00271 ////////////////////////////////////////////////////////////////////
00272 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00273 set_z(FLOATTYPE value) {
00274   _v.v._2 = value;
00275 }
00276 
00277 ////////////////////////////////////////////////////////////////////
00278 //     Function: LVecBase4::set_w
00279 //       Access: Public
00280 //  Description:
00281 ////////////////////////////////////////////////////////////////////
00282 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00283 set_w(FLOATTYPE value) {
00284   _v.v._3 = value;
00285 }
00286 
00287 ////////////////////////////////////////////////////////////////////
00288 //     Function: LVecBase4::get_data
00289 //       Access: Public
00290 //  Description: Returns the address of the first of the four data
00291 //               elements in the vector.  The remaining elements
00292 //               occupy the next positions consecutively in memory.
00293 ////////////////////////////////////////////////////////////////////
00294 INLINE_LINMATH const FLOATTYPE *FLOATNAME(LVecBase4)::
00295 get_data() const {
00296   return _v.data;
00297 }
00298 
00299 ////////////////////////////////////////////////////////////////////
00300 //     Function: LVecBase4::get_num_components
00301 //       Access: Public
00302 //  Description: Returns the number of elements in the vector, four.
00303 ////////////////////////////////////////////////////////////////////
00304 INLINE_LINMATH int FLOATNAME(LVecBase4)::
00305 get_num_components() const {
00306   return 4;
00307 }
00308 
00309 ////////////////////////////////////////////////////////////////////
00310 //     Function: LVecBase4::begin
00311 //       Access: Public
00312 //  Description: Returns an iterator that may be used to traverse the
00313 //               elements of the matrix, STL-style.
00314 ////////////////////////////////////////////////////////////////////
00315 INLINE_LINMATH FLOATNAME(LVecBase4)::iterator FLOATNAME(LVecBase4)::
00316 begin() {
00317   return _v.data;
00318 }
00319 
00320 ////////////////////////////////////////////////////////////////////
00321 //     Function: LVecBase4::end
00322 //       Access: Public
00323 //  Description: Returns an iterator that may be used to traverse the
00324 //               elements of the matrix, STL-style.
00325 ////////////////////////////////////////////////////////////////////
00326 INLINE_LINMATH FLOATNAME(LVecBase4)::iterator FLOATNAME(LVecBase4)::
00327 end() {
00328   return begin() + get_num_components();
00329 }
00330 
00331 ////////////////////////////////////////////////////////////////////
00332 //     Function: LVecBase4::begin
00333 //       Access: Public
00334 //  Description: Returns an iterator that may be used to traverse the
00335 //               elements of the matrix, STL-style.
00336 ////////////////////////////////////////////////////////////////////
00337 INLINE_LINMATH FLOATNAME(LVecBase4)::const_iterator FLOATNAME(LVecBase4)::
00338 begin() const {
00339   return _v.data;
00340 }
00341 
00342 ////////////////////////////////////////////////////////////////////
00343 //     Function: LVecBase4::end
00344 //       Access: Public
00345 //  Description: Returns an iterator that may be used to traverse the
00346 //               elements of the matrix, STL-style.
00347 ////////////////////////////////////////////////////////////////////
00348 INLINE_LINMATH FLOATNAME(LVecBase4)::const_iterator FLOATNAME(LVecBase4)::
00349 end() const {
00350   return begin() + get_num_components();
00351 }
00352 
00353 ////////////////////////////////////////////////////////////////////
00354 //     Function: LVecBase4::fill
00355 //       Access: Public
00356 //  Description: Sets each element of the vector to the indicated
00357 //               fill_value.  This is particularly useful for
00358 //               initializing to zero.
00359 ////////////////////////////////////////////////////////////////////
00360 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00361 fill(FLOATTYPE fill_value) {
00362   _v.v._0 = fill_value;
00363   _v.v._1 = fill_value;
00364   _v.v._2 = fill_value;
00365   _v.v._3 = fill_value;
00366 }
00367 
00368 ////////////////////////////////////////////////////////////////////
00369 //     Function: LVecBase4::set
00370 //       Access: Public
00371 //  Description:
00372 ////////////////////////////////////////////////////////////////////
00373 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00374 set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) {
00375   _v.v._0 = x;
00376   _v.v._1 = y;
00377   _v.v._2 = z;
00378   _v.v._3 = w;
00379 }
00380 
00381 ////////////////////////////////////////////////////////////////////
00382 //     Function: LVecBase4::dot
00383 //       Access: Public
00384 //  Description:
00385 ////////////////////////////////////////////////////////////////////
00386 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
00387 dot(const FLOATNAME(LVecBase4) &other) const {
00388   return
00389     _v.v._0 * other._v.v._0 + _v.v._1 * other._v.v._1 +
00390     _v.v._2 * other._v.v._2 + _v.v._3 * other._v.v._3;
00391 }
00392 
00393 ////////////////////////////////////////////////////////////////////
00394 //     Function: LVecBase4::operator <
00395 //       Access: Public
00396 //  Description: This performs a lexicographical comparison.  It's of
00397 //               questionable mathematical meaning, but sometimes has
00398 //               a practical purpose for sorting unique vectors,
00399 //               especially in an STL container.  Also see
00400 //               compare_to().
00401 ////////////////////////////////////////////////////////////////////
00402 INLINE_LINMATH bool FLOATNAME(LVecBase4)::
00403 operator < (const FLOATNAME(LVecBase4) &other) const {
00404   return (compare_to(other) < 0);
00405 }
00406 
00407 ////////////////////////////////////////////////////////////////////
00408 //     Function: LVecBase4::operator ==
00409 //       Access: Public
00410 //  Description:
00411 ////////////////////////////////////////////////////////////////////
00412 INLINE_LINMATH bool FLOATNAME(LVecBase4)::
00413 operator == (const FLOATNAME(LVecBase4) &other) const {
00414   return (_v.v._0 == other._v.v._0 &&
00415           _v.v._1 == other._v.v._1 &&
00416           _v.v._2 == other._v.v._2 &&
00417           _v.v._3 == other._v.v._3);
00418 }
00419 
00420 ////////////////////////////////////////////////////////////////////
00421 //     Function: LVecBase4::operator !=
00422 //       Access: Public
00423 //  Description:
00424 ////////////////////////////////////////////////////////////////////
00425 INLINE_LINMATH bool FLOATNAME(LVecBase4)::
00426 operator != (const FLOATNAME(LVecBase4) &other) const {
00427   return !operator == (other);
00428 }
00429 
00430 ////////////////////////////////////////////////////////////////////
00431 //     Function: LVecBase4::compare_to
00432 //       Access: Public
00433 //  Description: This flavor of compare_to uses a default threshold
00434 //               value based on the numeric type.
00435 ////////////////////////////////////////////////////////////////////
00436 INLINE_LINMATH int FLOATNAME(LVecBase4)::
00437 compare_to(const FLOATNAME(LVecBase4) &other) const {
00438   return compare_to(other, NEARLY_ZERO(FLOATTYPE));
00439 }
00440 
00441 ////////////////////////////////////////////////////////////////////
00442 //     Function: LVecBase4::compare_to
00443 //       Access: Public
00444 //  Description: Sorts vectors lexicographically, componentwise.
00445 //               Returns a number less than 0 if this vector sorts
00446 //               before the other one, greater than zero if it sorts
00447 //               after, 0 if they are equivalent (within the indicated
00448 //               tolerance).
00449 ////////////////////////////////////////////////////////////////////
00450 INLINE_LINMATH int FLOATNAME(LVecBase4)::
00451 compare_to(const FLOATNAME(LVecBase4) &other, FLOATTYPE threshold) const {
00452   if (!IS_THRESHOLD_COMPEQ(_v.v._0, other._v.v._0, threshold)) {
00453     return (_v.v._0 < other._v.v._0) ? -1 : 1;
00454   }
00455   if (!IS_THRESHOLD_COMPEQ(_v.v._1, other._v.v._1, threshold)) {
00456     return (_v.v._1 < other._v.v._1) ? -1 : 1;
00457   }
00458   if (!IS_THRESHOLD_COMPEQ(_v.v._2, other._v.v._2, threshold)) {
00459     return (_v.v._2 < other._v.v._2) ? -1 : 1;
00460   }
00461   if (!IS_THRESHOLD_COMPEQ(_v.v._3, other._v.v._3, threshold)) {
00462     return (_v.v._3 < other._v.v._3) ? -1 : 1;
00463   }
00464   return 0;
00465 }
00466 
00467 ////////////////////////////////////////////////////////////////////
00468 //     Function: LVecBase4::unary -
00469 //       Access: Public
00470 //  Description:
00471 ////////////////////////////////////////////////////////////////////
00472 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
00473 operator - () const {
00474   return FLOATNAME(LVecBase4)(-_v.v._0, -_v.v._1, -_v.v._2, -_v.v._3);
00475 }
00476 
00477 ////////////////////////////////////////////////////////////////////
00478 //     Function: LVecBase4::vector + vector
00479 //       Access: Public
00480 //  Description:
00481 ////////////////////////////////////////////////////////////////////
00482 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
00483 operator + (const FLOATNAME(LVecBase4) &other) const {
00484   return FLOATNAME(LVecBase4)(_v.v._0 + other._v.v._0,
00485                               _v.v._1 + other._v.v._1,
00486                               _v.v._2 + other._v.v._2,
00487                               _v.v._3 + other._v.v._3);
00488 }
00489 
00490 ////////////////////////////////////////////////////////////////////
00491 //     Function: LVecBase4::vector - vector
00492 //       Access: Public
00493 //  Description:
00494 ////////////////////////////////////////////////////////////////////
00495 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
00496 operator - (const FLOATNAME(LVecBase4) &other) const {
00497   return FLOATNAME(LVecBase4)(_v.v._0 - other._v.v._0,
00498                               _v.v._1 - other._v.v._1,
00499                               _v.v._2 - other._v.v._2,
00500                               _v.v._3 - other._v.v._3);
00501 }
00502 
00503 ////////////////////////////////////////////////////////////////////
00504 //     Function: LVecBase4::vector * scalar
00505 //       Access: Public
00506 //  Description:
00507 ////////////////////////////////////////////////////////////////////
00508 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
00509 operator * (FLOATTYPE scalar) const {
00510   return FLOATNAME(LVecBase4)(_v.v._0 * scalar,
00511                               _v.v._1 * scalar,
00512                               _v.v._2 * scalar,
00513                               _v.v._3 * scalar);
00514 }
00515 
00516 ////////////////////////////////////////////////////////////////////
00517 //     Function: LVecBase4::vector / scalar
00518 //       Access: Public
00519 //  Description:
00520 ////////////////////////////////////////////////////////////////////
00521 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
00522 operator / (FLOATTYPE scalar) const {
00523   FLOATTYPE recip_scalar = 1.0f/scalar;
00524   return FLOATNAME(LVecBase4)(_v.v._0 * recip_scalar,
00525                               _v.v._1 * recip_scalar,
00526                               _v.v._2 * recip_scalar,
00527                               _v.v._3 * recip_scalar);
00528 }
00529 
00530 ////////////////////////////////////////////////////////////////////
00531 //     Function: LVecBase4::operator +=
00532 //       Access: Public
00533 //  Description:
00534 ////////////////////////////////////////////////////////////////////
00535 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00536 operator += (const FLOATNAME(LVecBase4) &other) {
00537   _v.v._0 += other._v.v._0;
00538   _v.v._1 += other._v.v._1;
00539   _v.v._2 += other._v.v._2;
00540   _v.v._3 += other._v.v._3;
00541 }
00542 
00543 ////////////////////////////////////////////////////////////////////
00544 //     Function: LVecBase4::operator -=
00545 //       Access: Public
00546 //  Description:
00547 ////////////////////////////////////////////////////////////////////
00548 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00549 operator -= (const FLOATNAME(LVecBase4) &other) {
00550   _v.v._0 -= other._v.v._0;
00551   _v.v._1 -= other._v.v._1;
00552   _v.v._2 -= other._v.v._2;
00553   _v.v._3 -= other._v.v._3;
00554 }
00555 
00556 ////////////////////////////////////////////////////////////////////
00557 //     Function: LVecBase4::operator *=
00558 //       Access: Public
00559 //  Description:
00560 ////////////////////////////////////////////////////////////////////
00561 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00562 operator *= (FLOATTYPE scalar) {
00563   _v.v._0 *= scalar;
00564   _v.v._1 *= scalar;
00565   _v.v._2 *= scalar;
00566   _v.v._3 *= scalar;
00567 }
00568 
00569 ////////////////////////////////////////////////////////////////////
00570 //     Function: LVecBase4::operator /=
00571 //       Access: Public
00572 //  Description:
00573 ////////////////////////////////////////////////////////////////////
00574 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00575 operator /= (FLOATTYPE scalar) {
00576   FLOATTYPE recip_scalar = 1.0f/scalar;
00577   _v.v._0 *= recip_scalar;
00578   _v.v._1 *= recip_scalar;
00579   _v.v._2 *= recip_scalar;
00580   _v.v._3 *= recip_scalar;
00581 }
00582 
00583 ////////////////////////////////////////////////////////////////////
00584 //     Function: LVecBase4::almost_equal
00585 //       Access: Public
00586 //  Description: Returns true if two vectors are memberwise equal
00587 //               within a specified tolerance.
00588 ////////////////////////////////////////////////////////////////////
00589 INLINE_LINMATH bool FLOATNAME(LVecBase4)::
00590 almost_equal(const FLOATNAME(LVecBase4) &other, FLOATTYPE threshold) const {
00591   return (IS_THRESHOLD_EQUAL(_v.v._0, other._v.v._0, threshold) &&
00592           IS_THRESHOLD_EQUAL(_v.v._1, other._v.v._1, threshold) &&
00593           IS_THRESHOLD_EQUAL(_v.v._2, other._v.v._2, threshold) &&
00594           IS_THRESHOLD_EQUAL(_v.v._3, other._v.v._3, threshold));
00595 }
00596 
00597 ////////////////////////////////////////////////////////////////////
00598 //     Function: LVecBase4::almost_equal
00599 //       Access: Public
00600 //  Description: Returns true if two vectors are memberwise equal
00601 //               within a default tolerance based on the numeric type.
00602 ////////////////////////////////////////////////////////////////////
00603 INLINE_LINMATH bool FLOATNAME(LVecBase4)::
00604 almost_equal(const FLOATNAME(LVecBase4) &other) const {
00605   return almost_equal(other, NEARLY_ZERO(FLOATTYPE));
00606 }
00607 
00608 ////////////////////////////////////////////////////////////////////
00609 //     Function: LVecBase4::output
00610 //       Access: Public
00611 //  Description:
00612 ////////////////////////////////////////////////////////////////////
00613 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00614 output(ostream &out) const {
00615   out << MAYBE_ZERO(_v.v._0) << " "
00616       << MAYBE_ZERO(_v.v._1) << " "
00617       << MAYBE_ZERO(_v.v._2) << " "
00618       << MAYBE_ZERO(_v.v._3);
00619 }
00620 
00621 ////////////////////////////////////////////////////////////////////
00622 //     Function: LVecBase4::generate_hash
00623 //       Access: Public
00624 //  Description: Adds the vector to the indicated hash generator.
00625 ////////////////////////////////////////////////////////////////////
00626 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00627 generate_hash(ChecksumHashGenerator &hashgen) const {
00628   generate_hash(hashgen, NEARLY_ZERO(FLOATTYPE));
00629 }
00630 
00631 ////////////////////////////////////////////////////////////////////
00632 //     Function: LVecBase4::generate_hash
00633 //       Access: Public
00634 //  Description: Adds the vector to the indicated hash generator.
00635 ////////////////////////////////////////////////////////////////////
00636 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00637 generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const {
00638   hashgen.add_fp(_v.v._0, threshold);
00639   hashgen.add_fp(_v.v._1, threshold);
00640   hashgen.add_fp(_v.v._2, threshold);
00641   hashgen.add_fp(_v.v._3, threshold);
00642 }
00643 
00644 ////////////////////////////////////////////////////////////////////
00645 //     Function: LVecBase4::write_datagram
00646 //       Access: Public
00647 //  Description: Function to write itself into a datagram
00648 ////////////////////////////////////////////////////////////////////
00649 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00650 write_datagram(Datagram &destination) const {
00651   destination.add_float32(_v.v._0);
00652   destination.add_float32(_v.v._1);
00653   destination.add_float32(_v.v._2);
00654   destination.add_float32(_v.v._3);
00655 }
00656 
00657 ////////////////////////////////////////////////////////////////////
00658 //     Function: LVecBase4::read_datagram
00659 //       Access: Public
00660 //  Description: Function to read itself from a datagramIterator
00661 ////////////////////////////////////////////////////////////////////
00662 INLINE_LINMATH void FLOATNAME(LVecBase4)::
00663 read_datagram(DatagramIterator &source) {
00664   _v.v._0 = source.get_float32();
00665   _v.v._1 = source.get_float32();
00666   _v.v._2 = source.get_float32();
00667   _v.v._3 = source.get_float32();
00668 }

Generated on Fri May 2 00:40:17 2003 for Panda by doxygen1.3