#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/Math/LinearAlgebra/FixedSize/FVector.hh" // This file is part of RAVL, Recognition And Vision Library // Copyright (C) 2001, University of Surrey // This code may be redistributed under the terms of the GNU Lesser // General Public License (LGPL). See the lgpl.licence file for details or // see http://www.gnu.org/copyleft/lesser.html // file-header-ends-here #ifndef RAVL_FVECTOR_HEADER #define RAVL_FVECTOR_HEADER 1 ////////////////////////////////////////////////// //! rcsid=$Id: FVector.hh,v 1.11 2002/07/22 13:15:41 craftit Exp $ //! file="Ravl/Math/LinearAlgebra/FixedSize/FVector.hh" //! lib=RavlMath //! userlevel=Develop //! author="Charles Galambos" //! date="24/01/2001" //! docentry="Ravl.Math.Geometry" #include "Ravl/TFVector.hh" #include "Ravl/StdMath.hh" namespace RavlN { template class TFPointC; template class FMatrixC; //! userlevel=Advanced //: Real Vector with templated size template class FVectorC : public TFVectorC { public: FVectorC() {} //: Default constructor. FVectorC(const TFVectorC &oth) : TFVectorC(oth) {} //: Base constructor. explicit FVectorC(const TFPointC &oth) : TFVectorC(oth) {} //: Base constructor. bool IsReal() const { for(UIntT i = 0;i < N;i++) if(IsNan(data[i]) || IsInf(data[i])) return false; return true; } //: Test if matrix only contains real values. // This will return false if either nan's (Not an number) // or infinite values are found. RealT Magnitude() const { return Sqrt(SumSqr()); } //: Calculate the magintude of the vector. inline RealT EuclidDistance(const TFVectorC & i) const { return Sqrt(SqrEuclidDistance(i)); } //: Returns the magintude of the difference between the two vectors. FVectorC Unit() const { FVectorC ret; RealT mag = Magnitude(); for(UIntT i = 0;i < N;i++) ret[i] = data[i] / mag; return ret; } //: Create a unit vector with the same direction. const FVectorC &MakeUnit() { RealT mag = Magnitude(); for(UIntT i = 0;i < N;i++) data[i] /= mag; return *this; } //: Make this a unit vector. // In place operation. }; } #endif