mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 04:03:35 +08:00
Add helpers based on Slice: row(), col(), xy()
This commit is contained in:
+3
-3
@@ -166,9 +166,9 @@ public:
|
||||
void renormalize()
|
||||
{
|
||||
/* renormalize rows */
|
||||
for (size_t row = 0; row < 3; row++) {
|
||||
matrix::Vector3f rvec(this->_data[row]);
|
||||
this->setRow(row, rvec.normalized());
|
||||
for (size_t r = 0; r < 3; r++) {
|
||||
matrix::Vector3<Type> rvec(Matrix<Type,1,3>(this->Matrix<Type,3,3>::row(r)).transpose());
|
||||
this->Matrix<Type,3,3>::row(r) = rvec.normalized();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+25
-10
@@ -381,20 +381,35 @@ public:
|
||||
return Slice<Type, P, Q, M, N>(x0, y0, this);
|
||||
}
|
||||
|
||||
void setRow(size_t i, const Matrix<Type, N, 1> &row)
|
||||
const Slice<Type, 1, N, M, N> row(size_t i) const
|
||||
{
|
||||
Matrix<Type, M, N> &self = *this;
|
||||
for (size_t j = 0; j < N; j++) {
|
||||
self(i, j) = row(j, 0);
|
||||
}
|
||||
return slice<1, N>(i,0);
|
||||
}
|
||||
|
||||
void setCol(size_t j, const Matrix<Type, M, 1> &col)
|
||||
Slice<Type, 1, N, M, N> row(size_t i)
|
||||
{
|
||||
Matrix<Type, M, N> &self = *this;
|
||||
for (size_t i = 0; i < M; i++) {
|
||||
self(i, j) = col(i, 0);
|
||||
}
|
||||
return slice<1, N>(i,0);
|
||||
}
|
||||
|
||||
const Slice<Type, M, 1, M, N> col(size_t j) const
|
||||
{
|
||||
return slice<M, 1>(0,j);
|
||||
}
|
||||
|
||||
Slice<Type, M, 1, M, N> col(size_t j)
|
||||
{
|
||||
return slice<M, 1>(0,j);
|
||||
}
|
||||
|
||||
void setRow(size_t i, const Matrix<Type, N, 1> &row_in)
|
||||
{
|
||||
slice<1,N>(i,0) = row_in.transpose();
|
||||
}
|
||||
|
||||
|
||||
void setCol(size_t j, const Matrix<Type, M, 1> &column)
|
||||
{
|
||||
slice<M,1>(0,j) = column;
|
||||
}
|
||||
|
||||
void setZero()
|
||||
|
||||
@@ -109,6 +109,16 @@ public:
|
||||
return unit();
|
||||
}
|
||||
|
||||
const Slice<Type, 2, 1, 3, 1> xy() const
|
||||
{
|
||||
return Slice<Type, 2, 1, 3, 1>(0, 0, this);
|
||||
}
|
||||
|
||||
Slice<Type, 2, 1, 3, 1> xy()
|
||||
{
|
||||
return Slice<Type, 2, 1, 3, 1>(0, 0, this);
|
||||
}
|
||||
|
||||
|
||||
Dcm<Type> hat() const { // inverse to Dcm.vee() operation
|
||||
const Vector3 &v(*this);
|
||||
|
||||
Reference in New Issue
Block a user