18 #ifndef itkCovariantVector_h
19 #define itkCovariantVector_h
23 #include "vnl/vnl_vector_ref.h"
66 template<
typename T,
unsigned int NVectorDimension = 3 >
83 static constexpr
unsigned int Dimension = NVectorDimension;
93 {
return NVectorDimension; }
96 void SetVnlVector(
const vnl_vector< T > &);
99 vnl_vector_ref< T > GetVnlVector();
102 vnl_vector< T > GetVnlVector()
const;
120 template<
typename TVectorValueType >
127 template<
typename TCovariantVectorValueType >
130 BaseArray::operator=(r);
139 template<
typename Tt >
142 for (
unsigned int i = 0; i < NVectorDimension; i++ )
144 ( *this )[i] =
static_cast< ValueType >( ( *this )[i] * value );
151 template<
typename Tt >
154 for (
unsigned int i = 0; i < NVectorDimension; i++ )
156 ( *this )[i] =
static_cast< ValueType >( ( *this )[i] / value );
163 const Self & operator+=(
const Self & vec);
166 const Self & operator-=(
const Self & vec);
194 for (
unsigned int i = 0; i < NVectorDimension; i++ )
196 result[i] =
static_cast< ValueType >( ( *this )[i] * val );
203 template<
typename Tt >
208 for (
unsigned int i = 0; i < NVectorDimension; i++ )
210 result[i] =
static_cast< ValueType >( ( *this )[i] / val );
216 RealValueType GetNorm()
const;
222 RealValueType Normalize();
225 RealValueType GetSquaredNorm()
const;
229 template<
typename TCoordRepB >
232 for (
unsigned int i = 0; i < NVectorDimension; i++ )
234 ( *this )[i] =
static_cast< T
>( pa[i] );
242 template<
typename T,
unsigned int NVectorDimension >
244 CovariantVector< T, NVectorDimension >
247 return v.operator*(scalar);
252 template<
typename T,
unsigned int NVectorDimension >
257 return covariant.operator*( contravariant );
264 ITKCommon_EXPORT
void CrossProduct(CovariantVector< float, 3 > &,
265 const Vector< float, 3 > &,
266 const Vector< float, 3 > &);
268 ITKCommon_EXPORT
void CrossProduct(CovariantVector< int, 3 >,
269 const Vector< int, 3 > &,
270 const Vector< int, 3 > &);
273 template<
typename T,
unsigned int NVectorDimension >
291 #ifndef ITK_MANUAL_INSTANTIATION
292 #include "itkCovariantVector.hxx"
void swap(FixedArray &other)
void CastFrom(const CovariantVector< TCoordRepB, NVectorDimension > &pa)
ConstNeighborhoodIterator< TImage > operator-(const ConstNeighborhoodIterator< TImage > &it, const typename ConstNeighborhoodIterator< TImage >::OffsetType &ind)
Define numeric traits for std::vector.
const Self & operator/=(const Tt &value)
Self operator*(const ValueType &val) const
CovariantVector< T, NVectorDimension > operator*(const T &scalar, const CovariantVector< T, NVectorDimension > &v)
CovariantVector(const ValueType r[Dimension])
typename NumericTraits< ValueType >::RealType RealValueType
constexpr unsigned int Dimension
Simulate a standard C array with copy semnatics.
void swap(Array< T > &a, Array< T > &b)
CovariantVector(const CovariantVector< TVectorValueType, NVectorDimension > &r)
A templated class holding a n-Dimensional vector.
ConstNeighborhoodIterator< TImage > operator+(const ConstNeighborhoodIterator< TImage > &it, const typename ConstNeighborhoodIterator< TImage >::OffsetType &ind)
Self & operator=(const CovariantVector< TCovariantVectorValueType, NVectorDimension > &r)
ITKCommon_EXPORT void CrossProduct(CovariantVector< double, 3 > &, const Vector< double, 3 > &, const Vector< double, 3 > &)
Self operator/(const Tt &val) const
static unsigned int GetNumberOfComponents()
A templated class holding a n-Dimensional covariant vector.
const Self & operator*=(const Tt &value)
static unsigned int GetCovariantVectorDimension()