44struct traits<AlignedVector3<Scalar_> > : traits<Matrix<Scalar_, 3, 1, 0, 4, 1> > {};
48class AlignedVector3 :
public MatrixBase<AlignedVector3<Scalar_> > {
54 EIGEN_DENSE_PUBLIC_INTERFACE(AlignedVector3)
55 using Base::operator*;
57 inline Index rows()
const {
return 3; }
58 inline Index cols()
const {
return 1; }
60 Scalar* data() {
return m_coeffs.data(); }
61 const Scalar* data()
const {
return m_coeffs.data(); }
62 Index innerStride()
const {
return 1; }
63 Index outerStride()
const {
return 3; }
69 inline const Scalar& coeff(
Index index)
const {
return m_coeffs.coeff(index); }
71 inline Scalar& coeffRef(
Index index) {
return m_coeffs.coeffRef(index); }
73 inline AlignedVector3() {}
77 inline AlignedVector3(
const AlignedVector3& other) : Base(), m_coeffs(other.m_coeffs) {}
79 template <
typename XprType,
int Size = XprType::SizeAtCompileTime>
80 struct generic_assign_selector {};
82 template <
typename XprType>
83 struct generic_assign_selector<XprType, 4> {
84 inline static void run(AlignedVector3& dest,
const XprType& src) { dest.m_coeffs = src; }
87 template <
typename XprType>
88 struct generic_assign_selector<XprType, 3> {
89 inline static void run(AlignedVector3& dest,
const XprType& src) {
90 dest.m_coeffs.template
head<3>() = src;
91 dest.m_coeffs.w() =
Scalar(0);
95 template <
typename Derived>
97 generic_assign_selector<Derived>::run(*
this, other.derived());
100 inline AlignedVector3& operator=(
const AlignedVector3& other) {
101 m_coeffs = other.m_coeffs;
105 template <
typename Derived>
107 generic_assign_selector<Derived>::run(*
this, other.derived());
111 inline AlignedVector3 operator+(
const AlignedVector3& other)
const {
112 return AlignedVector3(m_coeffs + other.m_coeffs);
115 inline AlignedVector3& operator+=(
const AlignedVector3& other) {
116 m_coeffs += other.m_coeffs;
120 inline AlignedVector3 operator-(
const AlignedVector3& other)
const {
121 return AlignedVector3(m_coeffs - other.m_coeffs);
124 inline AlignedVector3 operator-()
const {
return AlignedVector3(-m_coeffs); }
126 inline AlignedVector3 operator-=(
const AlignedVector3& other) {
127 m_coeffs -= other.m_coeffs;
131 inline AlignedVector3 operator*(
const Scalar& s)
const {
return AlignedVector3(m_coeffs * s); }
133 inline friend AlignedVector3 operator*(
const Scalar& s,
const AlignedVector3& vec) {
134 return AlignedVector3(s * vec.m_coeffs);
137 inline AlignedVector3& operator*=(
const Scalar& s) {
142 inline AlignedVector3 operator/(
const Scalar& s)
const {
return AlignedVector3(m_coeffs / s); }
144 inline AlignedVector3& operator/=(
const Scalar& s) {
149 inline Scalar dot(
const AlignedVector3& other)
const {
150 eigen_assert(m_coeffs.w() ==
Scalar(0));
151 eigen_assert(other.m_coeffs.w() ==
Scalar(0));
152 return m_coeffs.dot(other.m_coeffs);
155 inline void normalize() { m_coeffs /= norm(); }
157 inline AlignedVector3 normalized()
const {
return AlignedVector3(m_coeffs / norm()); }
159 inline Scalar sum()
const {
160 eigen_assert(m_coeffs.w() ==
Scalar(0));
161 return m_coeffs.sum();
164 inline Scalar squaredNorm()
const {
165 eigen_assert(m_coeffs.w() ==
Scalar(0));
166 return m_coeffs.squaredNorm();
169 inline Scalar norm()
const {
171 return sqrt(squaredNorm());
174 inline AlignedVector3 cross(
const AlignedVector3& other)
const {
175 return AlignedVector3(m_coeffs.cross3(other.m_coeffs));
178 template <
typename Derived>
181 return m_coeffs.template
head<3>().isApprox(other, eps);
184 CoeffType& coeffs() {
return m_coeffs; }
185 const CoeffType& coeffs()
const {
return m_coeffs; }