#include <OSGVector.h>
Inheritance diagram for osg::VectorInterface< ValueTypeT, StorageInterfaceT >:

Public Types | |
| typedef PointInterface< ValueTypeT, StorageInterfaceT > | Inherited |
| Parent type. | |
| typedef TypeTraits< ValueTypeT >::RealReturnType | RealReturnType |
| Used type if the returnvalue must be a real value. | |
| typedef ValueTypeT | ValueType |
| Value type. | |
| typedef Inherited | PntInterface |
| typedef VectorInterface< ValueTypeT, StorageInterfaceT > | Self |
| Own type. | |
| typedef VectorInterface< ValueTypeT, StorageInterfaceT > | VecInterface |
Public Member Functions | |
Constructors | |
| * | VectorInterface (void) |
| VectorInterface (const ValueTypeT *pVals) | |
| Constructor which takes a const value array. | |
| VectorInterface (ValueTypeT *pVals) | |
| Constructor which takes a const value array. | |
| template<class VectorT> | |
| VectorInterface (const VectorT &vec) | |
| VectorInterface (const VectorInterface &source) | |
| VectorInterface (const ValueTypeT rVal1, const ValueTypeT rVal2) | |
| VectorInterface (const ValueTypeT rVal1, const ValueTypeT rVal2, const ValueTypeT rVal3) | |
| VectorInterface (const ValueTypeT rVal1, const ValueTypeT rVal2, const ValueTypeT rVal3, const ValueTypeT rVal4) | |
Destructor | |
| * | ~VectorInterface (void) |
Common Math | |
| *RealReturnType | length (void) const |
| Euclidean length of the vector. | |
| RealReturnType | squareLength (void) const |
| square of the Euclidean length of the vector | |
| void | normalize (void) |
| Changes vector to be of unit length. | |
| VectorInterface | cross (const VectorInterface &vec) const |
| Returns the right handed cross-product for a given vector; This function is implemented for size 3 vectors only. | |
| VectorInterface | operator% (const VectorInterface &vec) const |
| Euclidean length of the vector. | |
| void | crossThis (const VectorInterface &vec) |
| Calculates the right handed cross-product with a given vector; This function is implemented for size 3 vectors only. | |
| ValueTypeT | dot (const VectorInterface &vec) const |
| Return the dot (inner) product for a given vector. | |
| ValueTypeT | operator * (const VectorInterface &vec) const |
| Euclidean length of the vector. | |
| ValueTypeT | dot (const PntInterface &pnt) const |
| Euclidean length of the vector. | |
| ValueTypeT | operator * (const PntInterface &pnt) const |
| Euclidean length of the vector. | |
| RealReturnType | enclosedAngle (const VectorInterface &vec) const |
| Returns the angle between this and another vector. | |
| RealReturnType | projectTo (const VectorInterface &toVec) |
| Euclidean length of the vector. | |
Conv | |
| *PntInterface & | addToZero (void) |
| Returns the corrosponding point by adding it to zero. | |
| const PntInterface & | addToZero (void) const |
| Returns the corrosponding point by adding it to zero. | |
| VectorInterface & | subZero (void) |
| Returns the corrosponding point by adding it to zero. | |
| const VectorInterface & | subZero (void) const |
| Returns the corrosponding point by adding it to zero. | |
Math | |
| *VectorInterface | operator- (const VectorInterface &vec) const |
| Component wise binary vector subtraction operator. | |
| VectorInterface | operator+ (const VectorInterface &vec) const |
| Component wise binary vector addition operator. | |
| VectorInterface | operator * (const ValueTypeT rVal) const |
| Component wise binary scalar multiplication. | |
| VectorInterface | operator- (void) const |
| Nondestructive unary negation, returns new vector. | |
Assignment | |
| *VectorInterface & | operator= (const VectorInterface &source) |
Comparison | |
| *bool | operator< (const VectorInterface &other) const |
| bool | operator== (const VectorInterface &other) const |
| Equal operator, using Eps as the tolerance. | |
| bool | operator!= (const VectorInterface &other) const |
| Not eual operator, using Eps as the tolerance. | |
Set Values | |
| *void | setNull (void) |
| void | setValue (const PointInterface &vec) |
| template<class VectorT> | |
| void | setValue (const VectorT &vec) |
| void | setValue (const ValueTypeT *pVals) |
| Set value from a given array, be sure to match sizes. | |
| void | setValue (ValueTypeT *pVals) |
| Set value from a given array, be sure to match sizes. | |
| void | setValue (const Char8 *szString) |
| void | setValue (Char8 *szString) |
| void | setValueFromCString (const Char8 *szString) |
| Extract values from given string, where both (const and not const) must be present, otherwise the compiler strikes back :-) (GV). | |
| void | setValueFromCString (Char8 *szString) |
| Extract values from given string, where both (const and not const) must be present, otherwise the compiler strikes back :-) (GV). | |
Get Values | |
| *ValueTypeT * | getValues (void) |
| Get a pointer to the value storage. | |
| const ValueTypeT * | getValues (void) const |
| Get a const pointer to the value storage. | |
Common Math | |
| *bool | isZero (void) const |
| Returns true iff the norm of each value is less than Eps. | |
| void | negate (void) |
| Negates each value of the point in place. | |
| bool | equals (const PointInterface &vec, const ValueTypeT tolerance) const |
| Returns true iff the two points are eual within a given tolerance. | |
| RealReturnType | dist (const PointInterface &vec) const |
| Returns the distance between the two points. | |
| RealReturnType | dist2 (const PointInterface &vec) const |
| Returns the distance between the two points, squared. | |
| RealReturnType | maxValue (void) const |
| Returns the maximum value of the vector. | |
Math | |
| *void | operator *= (const ValueTypeT val) |
| Component wise scalar multiplication. | |
| void | operator/= (const ValueTypeT val) |
| Component wise scalar division. | |
| VecInterface | operator- (const PointInterface &vec) const |
| Point substraction, returns a new vector. | |
| PointInterface | operator- (void) |
| Nondestructive unary negation, returns new point. | |
| void | operator+= (const VecInterface &vec) |
| Component wise vector addition. | |
| void | operator-= (const VecInterface &vec) |
| Component wise vector substraction. | |
Element Access | |
| *ValueTypeT & | operator[] (const UInt32 uiVal) |
| const ValueTypeT & | operator[] (const UInt32 uiVal) const |
Comparison | |
| *bool | operator< (const PointInterface &other) const |
| bool | operator== (const PointInterface &other) const |
| Equal operator, using Eps as the tolerance. | |
| bool | operator!= (const PointInterface &other) const |
| Not equal operator, using Eps as the tolerance. | |
Static Public Attributes | |
| static const VectorInterface | Null |
Definition at line 536 of file OSGVector.h.
|
|||||
|
Reimplemented from osg::PointInterface< ValueTypeT, StorageInterfaceT >. Definition at line 544 of file OSGVector.h. |
|
|||||
|
Reimplemented from osg::PointInterface< ValueTypeT, StorageInterfaceT >. Definition at line 546 of file OSGVector.h. |
|
|||||
|
Reimplemented from osg::PointInterface< ValueTypeT, StorageInterfaceT >. Definition at line 548 of file OSGVector.h. |
|
|||||
|
Definition at line 550 of file OSGVector.h. |
|
|||||
|
Reimplemented from osg::PointInterface< ValueTypeT, StorageInterfaceT >. Definition at line 553 of file OSGVector.h. |
|
|||||
|
Definition at line 296 of file OSGVector.h. |
|
||||||||||
|
Definition at line 1306 of file OSGVector.inl. 01306 : 01307 Inherited() 01308 { 01309 for(UInt32 i = 0; i < Self::_iSize; i++) 01310 { 01311 Self::_values[i] = TypeTraits<ValueTypeT>::getZeroElement(); 01312 } 01313 }
|
|
||||||||||
|
Be shure the array size at least as large as the vector size. Definition at line 1324 of file OSGVector.inl. 01324 : 01325 Inherited(pVals) 01326 { 01327 }
|
|
||||||||||
|
Be shure the array size at least as large as the vector size. Definition at line 1337 of file OSGVector.inl. 01337 : 01338 Inherited(pVals) 01339 { 01340 }
|
|
||||||||||||||
|
Definition at line 572 of file OSGVector.h. 00573 { 00574 if(Self::_iSize <= VectorT::_iSize) 00575 { 00576 for(UInt32 i = 0; i < Self::_iSize; i++) 00577 { 00578 Self::_values[i] = vec.getValues()[i]; 00579 } 00580 } 00581 else 00582 { 00583 UInt32 i; 00584 for(i = 0; i < VectorT::_iSize; i++) 00585 { 00586 Self::_values[i] = vec.getValues()[i]; 00587 } 00588 for(i = VectorT::_iSize; i < Self::_iSize; i++) 00589 { 00590 Self::_values[i] = TypeTraits<ValueTypeT>::getZeroElement(); 00591 } 00592 } 00593 }
|
|
||||||||||
|
Definition at line 1403 of file OSGVector.inl. 01404 : 01405 01406 Inherited(source) 01407 { 01408 }
|
|
||||||||||||||||
|
Definition at line 1430 of file OSGVector.inl. 01431 : 01432 01433 Inherited(rVal1, rVal2) 01434 { 01435 }
|
|
||||||||||||||||||||
|
Definition at line 1440 of file OSGVector.inl. 01442 : 01443 01444 Inherited(rVal1, rVal2, rVal3) 01445 { 01446 }
|
|
||||||||||||||||||||||||
|
Definition at line 1451 of file OSGVector.inl. 01454 : 01455 01456 Inherited(rVal1, rVal2, rVal3, rVal4) 01457 { 01458 }
|
|
||||||||||
|
Definition at line 1467 of file OSGVector.inl.
|
|
||||||||||
|
||||||||||
|
Definition at line 1489 of file OSGVector.inl. Referenced by osg::calcVertexNormals(), osg::Surface::FindClosestPoint(), osg::Surface::FindClosestPointExact(), osg::Line::getClosestPoints(), osg::Surface::getDesiredError(), and osg::VectorInterface< ValueTypeT, StorageInterfaceT >::length(). 01490 { 01491 RealReturnType rTmpVal = RealReturnType(Self::_values[0] * 01492 Self::_values[0] ); 01493 01494 for(UInt32 i = 1; i < Self::_iSize; i++) 01495 { 01496 rTmpVal += Self::_values[i] * Self::_values[i]; 01497 } 01498 01499 return rTmpVal; 01500 }
|
|
||||||||||
|
||||||||||
|
||||||||||
|
Definition at line 1565 of file OSGVector.inl. References osg::VectorInterface< ValueTypeT, StorageInterfaceT >::cross(). 01567 { 01568 return this->cross(vec); 01569 }
|
|
||||||||||
|
Definition at line 1578 of file OSGVector.inl. Referenced by osg::calcVertexNormals(), osg::WalkNavigator::forward(), osg::Plane::Plane(), osg::RAWSceneFileType::read(), osg::WalkNavigator::right(), osg::FlyNavigator::right(), osg::TrackballNavigator::rotate(), osg::FlyNavigator::rotate(), and osg::Trackball::updateRotation(). 01579 { 01580 if(Self::_iSize >= 3) 01581 { 01582 ValueTypeT rTmp[2]; 01583 01584 rTmp[0] = 01585 Self::_values[1] * vec._values[2] - 01586 Self::_values[2] * vec._values[1]; 01587 rTmp[1] = 01588 Self::_values[2] * vec._values[0] - 01589 Self::_values[0] * vec._values[2]; 01590 01591 Self::_values[2] = 01592 Self::_values[0] * vec._values[1] - 01593 Self::_values[1] * vec._values[0]; 01594 01595 Self::_values[0] = rTmp[0]; 01596 Self::_values[1] = rTmp[1]; 01597 } 01598 else 01599 { 01600 // Must be changed 01601 fprintf(stderr, "crossThis only available for size 3\n"); 01602 } 01603 }
|
|
||||||||||
|
||||||||||
|
Definition at line 1628 of file OSGVector.inl. References osg::VectorInterface< ValueTypeT, StorageInterfaceT >::dot(). 01630 { 01631 return this->dot(vec); 01632 }
|
|
||||||||||
|
Definition at line 1636 of file OSGVector.inl. 01638 { 01639 ValueTypeT rTmpVal = Self::_values[0] * pnt[0]; 01640 01641 for(UInt32 i = 1; i < Self::_iSize; i++) 01642 { 01643 rTmpVal += Self::_values[i] * pnt[i]; 01644 } 01645 01646 return rTmpVal; 01647 }
|
|
||||||||||
|
Definition at line 1651 of file OSGVector.inl. References osg::VectorInterface< ValueTypeT, StorageInterfaceT >::dot(). 01653 { 01654 return this->dot(pnt); 01655 }
|
|
||||||||||
|
Definition at line 1662 of file OSGVector.inl. References osg::VectorInterface< ValueTypeT, StorageInterfaceT >::dot(), osg::Eps, osg::PointInterface< ValueTypeT, StorageInterfaceT >::isZero(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::length(), osg::osgacos(), and osg::Pi. Referenced by osg::ExtrusionSurface::calcVertexNormal(), and osg::ExtrusionSurface::storeSweepSurfaceWithNormals(). 01664 { 01665 RealReturnType returnValue; 01666 01667 if(Self::isZero() || vec.isZero()) 01668 { 01669 returnValue = TypeTraits<RealReturnType>::getZeroElement(); 01670 } 01671 else 01672 { 01673 returnValue = dot(vec); 01674 returnValue /= (length() * vec.length()); 01675 01676 if((returnValue - Eps) < -1.) 01677 { 01678 returnValue = Pi; 01679 } 01680 else if((returnValue + Eps) > 1.) 01681 { 01682 returnValue = TypeTraits<RealReturnType>::getZeroElement(); 01683 } 01684 else 01685 { 01686 returnValue = osgacos(returnValue); 01687 } 01688 } 01689 01690 return returnValue; 01691 }
|
|
||||||||||
|
Definition at line 1696 of file OSGVector.inl. References osg::VectorInterface< ValueTypeT, StorageInterfaceT >::dot(), osg::Eps, osg::osgabs(), and osg::PointInterface< ValueTypeT, StorageInterfaceT >::setNull(). Referenced by osg::Plane::transform(). 01698 { 01699 RealReturnType rDot = dot(toVec); 01700 RealReturnType rSquareDot = toVec.dot(toVec); 01701 01702 if(rSquareDot > Eps) 01703 { 01704 rDot /= rSquareDot; 01705 01706 if(osgabs(rDot) > Eps) 01707 { 01708 *this = toVec; 01709 *this *= ValueTypeT(rDot); 01710 } 01711 else 01712 { 01713 this->setNull(); 01714 rDot = TypeTraits<RealReturnType>::getZeroElement(); 01715 } 01716 } 01717 else 01718 { 01719 rDot = TypeTraits<RealReturnType>::getOneElement(); 01720 } 01721 01722 return rDot; 01723 }
|
|
||||||||||
|
Definition at line 1744 of file OSGVector.inl. Referenced by osg::makeSphereGeo().
|
|
||||||||||
|
Definition at line 1732 of file OSGVector.inl.
|
|
||||||||||
|
Reimplemented from osg::PointInterface< ValueTypeT, StorageInterfaceT >. Definition at line 1752 of file OSGVector.inl.
|
|
||||||||||
|
Reimplemented from osg::PointInterface< ValueTypeT, StorageInterfaceT >. Definition at line 1760 of file OSGVector.inl.
|
|
||||||||||
|
Reimplemented from osg::PointInterface< ValueTypeT, StorageInterfaceT >. Definition at line 1773 of file OSGVector.inl. 01775 { 01776 VectorInterface<ValueTypeT, StorageInterfaceT> returnValue; 01777 01778 for(UInt32 i = 0; i < StorageInterfaceT::_iSize; i++) 01779 { 01780 returnValue[i] = Self::_values[i] - vec[i]; 01781 } 01782 01783 return returnValue; 01784 }
|
|
||||||||||
|
Reimplemented from osg::PointInterface< ValueTypeT, StorageInterfaceT >. Definition at line 1791 of file OSGVector.inl. 01793 { 01794 VectorInterface<ValueTypeT, StorageInterfaceT> returnValue; 01795 01796 for(UInt32 i = 0; i < StorageInterfaceT::_iSize; i++) 01797 { 01798 returnValue[i] = Self::_values[i] + vec[i]; 01799 } 01800 01801 return returnValue; 01802 }
|
|
||||||||||
|
Reimplemented from osg::PointInterface< ValueTypeT, StorageInterfaceT >. Definition at line 1810 of file OSGVector.inl. 01812 { 01813 VectorInterface<ValueTypeT, StorageInterfaceT> returnValue; 01814 01815 for(UInt32 i = 0; i < StorageInterfaceT::_iSize; i++) 01816 { 01817 returnValue[i] = Self::_values[i] * rVal; 01818 } 01819 01820 return returnValue; 01821 }
|
|
||||||||||
|
Definition at line 1828 of file OSGVector.inl. 01829 { 01830 VectorInterface<ValueTypeT, StorageInterfaceT> returnValue; 01831 01832 for(UInt32 i = 0; i < Self::_iSize; i++) 01833 { 01834 returnValue._values[i] = - Self::_values[i]; 01835 } 01836 01837 return returnValue; 01838 }
|
|
||||||||||
|
Reimplemented from osg::PointInterface< ValueTypeT, StorageInterfaceT >. Definition at line 1846 of file OSGVector.inl. 01848 { 01849 if(this == &source) 01850 return *this; 01851 01852 *(static_cast<Inherited *>(this)) = 01853 static_cast<const Inherited &>(source); 01854 01855 return *this; 01856 }
|
|
||||||||||
|
Definition at line 1863 of file OSGVector.inl. 01865 { 01866 bool ret = false; 01867 01868 for(UInt32 i = 0; i < Self::_iSize; i++) 01869 { 01870 if(Self::_values[i] < other._values[i]) 01871 { 01872 ret = true; 01873 break; 01874 } 01875 01876 if(Self::_values[i] > other._values[i]) 01877 break; 01878 } 01879 01880 return ret; 01881 }
|
| |||||||