42 : traits<Matrix<_Scalar,3,1,0,4,1> >
47template<
typename _Scalar>
class AlignedVector3
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; }
67 {
return m_coeffs.coeff(
row,
col); }
70 {
return m_coeffs.coeffRef(
row,
col); }
73 {
return m_coeffs.coeff(index); }
76 {
return m_coeffs.coeffRef(index);}
80 : m_coeffs(x, y, z,
Scalar(0))
83 inline AlignedVector3(
const AlignedVector3& other)
84 : Base(), m_coeffs(other.m_coeffs)
87 template<
typename XprType,
int Size=XprType::SizeAtCompileTime>
88 struct generic_assign_selector {};
90 template<
typename XprType>
struct generic_assign_selector<XprType,4>
92 inline static void run(AlignedVector3& dest,
const XprType& src)
98 template<
typename XprType>
struct generic_assign_selector<XprType,3>
100 inline static void run(AlignedVector3& dest,
const XprType& src)
102 dest.m_coeffs.template
head<3>() = src;
103 dest.m_coeffs.w() =
Scalar(0);
107 template<
typename Derived>
110 generic_assign_selector<Derived>::run(*
this,other.derived());
113 inline AlignedVector3& operator=(
const AlignedVector3& other)
114 { m_coeffs = other.m_coeffs;
return *
this; }
116 template <
typename Derived>
119 generic_assign_selector<Derived>::run(*
this,other.derived());
123 inline AlignedVector3 operator+(
const AlignedVector3& other)
const
124 {
return AlignedVector3(m_coeffs + other.m_coeffs); }
126 inline AlignedVector3& operator+=(
const AlignedVector3& other)
127 { m_coeffs += other.m_coeffs;
return *
this; }
129 inline AlignedVector3
operator-(
const AlignedVector3& other)
const
130 {
return AlignedVector3(m_coeffs - other.m_coeffs); }
132 inline AlignedVector3 operator-=(
const AlignedVector3& other)
133 { m_coeffs -= other.m_coeffs;
return *
this; }
135 inline AlignedVector3 operator*(
const Scalar& s)
const
136 {
return AlignedVector3(m_coeffs * s); }
138 inline friend AlignedVector3 operator*(
const Scalar& s,
const AlignedVector3& vec)
139 {
return AlignedVector3(s * vec.m_coeffs); }
141 inline AlignedVector3& operator*=(
const Scalar& s)
142 { m_coeffs *= s;
return *
this; }
144 inline AlignedVector3 operator/(
const Scalar& s)
const
145 {
return AlignedVector3(m_coeffs / s); }
147 inline AlignedVector3& operator/=(
const Scalar& s)
148 { m_coeffs /= s;
return *
this; }
150 inline Scalar dot(
const AlignedVector3& other)
const
152 eigen_assert(m_coeffs.w()==
Scalar(0));
153 eigen_assert(other.m_coeffs.w()==
Scalar(0));
154 return m_coeffs.dot(other.m_coeffs);
157 inline void normalize()
162 inline AlignedVector3 normalized()
const
164 return AlignedVector3(m_coeffs / norm());
169 eigen_assert(m_coeffs.w()==
Scalar(0));
170 return m_coeffs.sum();
173 inline Scalar squaredNorm()
const
175 eigen_assert(m_coeffs.w()==
Scalar(0));
176 return m_coeffs.squaredNorm();
179 inline Scalar norm()
const
182 return sqrt(squaredNorm());
185 inline AlignedVector3 cross(
const AlignedVector3& other)
const
187 return AlignedVector3(m_coeffs.cross3(other.m_coeffs));
190 template<
typename Derived>
193 return m_coeffs.template
head<3>().isApprox(other,eps);
196 CoeffType& coeffs() {
return m_coeffs; }
197 const CoeffType& coeffs()
const {
return m_coeffs; }