Covariant Vector Dot Product#
Synopsis#
Dot product of CovariantVectors
Results#
Output:
u :[-1, 1, -1]
v :[1, 2, 3]
DotProduct( u, v ) = -2
u - DotProduct( u, v ) * v = [1, 5, 5]
Code#
C++#
#include "itkCovariantVector.h"
int
main()
{
constexpr unsigned int Dimension = 3;
using CoordType = double;
using VectorType = itk::CovariantVector<CoordType, Dimension>;
VectorType u;
u[0] = -1.;
u[1] = 1.;
u[2] = -1.;
VectorType v;
v[0] = 1.;
v[1] = 2.;
v[2] = 3.;
std::cout << "u :" << u << std::endl;
std::cout << "v :" << v << std::endl;
std::cout << "DotProduct( u, v ) = " << u * v << std::endl;
std::cout << "u - ( u * v ) * v = " << u - (u * v) * v << std::endl;
return EXIT_SUCCESS;
}
Classes demonstrated#
-
template<typename T, unsigned int NVectorDimension = 3>
class CovariantVector : public itk::FixedArray<T, NVectorDimension> A templated class holding a n-Dimensional covariant vector.
CovariantVector is a templated class that holds a single vector (i.e., an array of values). CovariantVector can be used as the data type held at each pixel in an Image or at each vertex of an Mesh. The template parameter T can be any data type that behaves like a primitive (or atomic) data type (int, short, float, complex). The NVectorDimension defines the number of components in the vector array.
CovariantVector is not a dynamically extendible array like std::vector. It is intended to be used like a mathematical vector.
If you wish a simpler pixel types, you can use Scalar, which represents a single data value at a pixel. There is also the more complex type ScalarCovariantVector, which supports (for a given pixel) a single scalar value plus an array of vector values. (The scalar and vectors can be of different data type.)
CovariantVector is the type that should be used for representing normals to surfaces and gradients of functions. AffineTransform transform covariant vectors different than vectors.
- See
Image
- See
Mesh
- See
Point
- See
Vector
- See
Matrix
- ITK Sphinx Examples: