45struct traits<AlignedVector3<Scalar_> > : traits<Matrix<Scalar_, 3, 1, 0, 4, 1> > {};
49class AlignedVector3 :
public MatrixBase<AlignedVector3<Scalar_> > {
55 EIGEN_DENSE_PUBLIC_INTERFACE(AlignedVector3)
56 using Base::operator*;
58 inline Index rows()
const {
return 3; }
59 inline Index cols()
const {
return 1; }
61 Scalar* data() {
return m_coeffs.data(); }
62 const Scalar* data()
const {
return m_coeffs.data(); }
63 Index innerStride()
const {
return 1; }
64 Index outerStride()
const {
return 3; }
66 inline const Scalar& coeff(Index
row, Index
col)
const {
return m_coeffs.coeff(
row,
col); }
70 inline const Scalar& coeff(Index index)
const {
return m_coeffs.coeff(index); }
72 inline Scalar& coeffRef(Index index) {
return m_coeffs.coeffRef(index); }
74 inline AlignedVector3() {}
78 inline AlignedVector3(
const AlignedVector3& other) : Base(), m_coeffs(other.m_coeffs) {}
80 template <
typename XprType,
int Size = XprType::SizeAtCompileTime>
81 struct generic_assign_selector {};
83 template <
typename XprType>
84 struct generic_assign_selector<XprType, 4> {
85 inline static void run(AlignedVector3& dest,
const XprType& src) { dest.m_coeffs = src; }
88 template <
typename XprType>
89 struct generic_assign_selector<XprType, 3> {
90 inline static void run(AlignedVector3& dest,
const XprType& src) {
91 dest.m_coeffs.template
head<3>() = src;
92 dest.m_coeffs.w() =
Scalar(0);
96 template <
typename Derived>
98 generic_assign_selector<Derived>::run(*
this, other.derived());
101 inline AlignedVector3& operator=(
const AlignedVector3& other) {
102 m_coeffs = other.m_coeffs;
106 template <
typename Derived>
108 generic_assign_selector<Derived>::run(*
this, other.derived());
112 inline AlignedVector3 operator+(
const AlignedVector3& other)
const {
113 return AlignedVector3(m_coeffs + other.m_coeffs);
116 inline AlignedVector3& operator+=(
const AlignedVector3& other) {
117 m_coeffs += other.m_coeffs;
121 inline AlignedVector3 operator-(
const AlignedVector3& other)
const {
122 return AlignedVector3(m_coeffs - other.m_coeffs);
125 inline AlignedVector3 operator-()
const {
return AlignedVector3(-m_coeffs); }
127 inline AlignedVector3& operator-=(
const AlignedVector3& other) {
128 m_coeffs -= other.m_coeffs;
132 inline AlignedVector3 operator*(
const Scalar& s)
const {
return AlignedVector3(m_coeffs * s); }
134 inline friend AlignedVector3 operator*(
const Scalar& s,
const AlignedVector3& vec) {
135 return AlignedVector3(s * vec.m_coeffs);
138 inline AlignedVector3& operator*=(
const Scalar& s) {
143 inline AlignedVector3 operator/(
const Scalar& s)
const {
return AlignedVector3(m_coeffs / s); }
145 inline AlignedVector3& operator/=(
const Scalar& s) {
150 inline Scalar dot(
const AlignedVector3& other)
const {
151 eigen_assert(m_coeffs.w() ==
Scalar(0));
152 eigen_assert(other.m_coeffs.w() ==
Scalar(0));
153 return m_coeffs.dot(other.m_coeffs);
156 inline void normalize() { m_coeffs /= norm(); }
158 inline AlignedVector3 normalized()
const {
return AlignedVector3(m_coeffs / norm()); }
160 inline Scalar sum()
const {
161 eigen_assert(m_coeffs.w() ==
Scalar(0));
162 return m_coeffs.sum();
165 inline Scalar squaredNorm()
const {
166 eigen_assert(m_coeffs.w() ==
Scalar(0));
167 return m_coeffs.squaredNorm();
170 inline Scalar norm()
const {
172 return sqrt(squaredNorm());
175 inline AlignedVector3 cross(
const AlignedVector3& other)
const {
176 return AlignedVector3(m_coeffs.cross3(other.m_coeffs));
179 template <
typename Derived>
182 return m_coeffs.template
head<3>().isApprox(other, eps);
185 CoeffType& coeffs() {
return m_coeffs; }
186 const CoeffType& coeffs()
const {
return m_coeffs; }