本文整理汇总了C++中Matrix3f::transpose方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix3f::transpose方法的具体用法?C++ Matrix3f::transpose怎么用?C++ Matrix3f::transpose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix3f
的用法示例。
在下文中一共展示了Matrix3f::transpose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: correctionStep
void ExtendedKalmanFilter::correctionStep(const Eigen::Vector3f& measurement, const Eigen::Vector3f& global_marker_pose){ // compare expected and measured values, update state and uncertainty
// compute expected measurement:
Vector3f z_exp; // z_exp = h(x)
z_exp(0) = cos(state(2))*(global_marker_pose(0)- state(0)) + sin(state(2))*(global_marker_pose(1)-state(1));
z_exp(1) = -sin(state(2))*(global_marker_pose(0) -state(0)) + cos(state(2))*(global_marker_pose(1)-state(1));
z_exp(2) = global_marker_pose(2)-state(2);
Matrix3f H; // dh/dx
H << -cos(state(2)), -sin(state(2)), -sin(state(2))*(global_marker_pose(0) - state(0)) + cos(state(2))*(global_marker_pose(1)-state(1)),
sin(state(2)), -cos(state(2)), -cos(state(2))*(global_marker_pose(0) -state(0)) - sin(state(2))*(global_marker_pose(1)-state(1)),
0, 0, -1;
// cout << "H: " << endl << H << endl;
Matrix3f K = sigma * H.transpose() * ((H * sigma * H.transpose() + R).inverse()); // Kalman Gain
// compute the difference between expectation and observation
Vector3f z_diff = measurement - z_exp;
// normalize angle
z_diff(2) = atan2(sin(z_diff(2)),cos(z_diff(2)));
// cout << "z_exp: " << z_exp(0) << " "<< z_exp(1) << " "<< z_exp(2) << endl;
// cout << "diff: " << z_diff(0) << " "<< z_diff(1) << " "<< z_diff(2) << endl;
// correct pose estimate
state = state + K*( z_diff );
sigma = (Matrix3f::Identity() - K*H)*sigma;
}
示例2: m
float mmf::OptSO3vMFCF::conjugateGradientCUDA_impl(Matrix3f& R, float res0,
uint32_t n, uint32_t maxIter) {
Eigen::Matrix3f N = Eigen::Matrix3f::Zero();
// tauR_*R^T is the contribution of the motion prior between two
// frames to regularize solution in case data exists only on certain
// axes
if (this->t_ >= 1) N += tauR_*R.transpose();
for (uint32_t j=0; j<6; ++j) {
Eigen::Vector3f m = Eigen::Vector3f::Zero();
m(j/2) = j%2==0?1.:-1.;
N += m*this->cld_.xSums().col(j).transpose();
}
Eigen::JacobiSVD<Eigen::Matrix3f> svd(N,Eigen::ComputeThinU|Eigen::ComputeThinV);
if (svd.matrixV().determinant()*svd.matrixU().determinant() > 0)
R = svd.matrixV()*svd.matrixU().transpose();
else
R = svd.matrixV()*Eigen::Vector3f(1.,1.,-1.).asDiagonal()*svd.matrixU().transpose();
// if (R.determinant() < 0.) {
// //R *= -1.;
//// R = svd.matrixV()*Eigen::Vector3f(1.,1.,-1.).asDiagonal()*svd.matrixU().transpose();
// std::cout << "determinant of R < 0" << std::endl;
// }
// std::cout << R.determinant() << std::endl;
// std::cout << "N" << std::endl << N << std::endl;
// std::cout << "R" << std::endl << R << std::endl;
// std::cout << this->cld_.xSums() << std::endl;
return (N*R).trace();
}
示例3: update_Ri
void Deform::update_Ri()
{
Matrix3f Si;
MatrixXf Di;
Matrix3Xf Pi_Prime;
Matrix3Xf Pi;
for (int i = 0; i != P_Num; ++i) {
Di = MatrixXf::Zero(adj_list[i].size(), adj_list[i].size());
Pi_Prime.resize(3, adj_list[i].size());
Pi.resize(3, adj_list[i].size());
// if there is not any single unconnected point this for loop can have a more efficient representation
for (decltype(adj_list[i].size()) j = 0; j != adj_list[i].size(); ++j) {
Di(j, j) = Weight.coeffRef(i, adj_list[i][j]);
Pi.col(j) = P.col(i) - P.col(adj_list[i][j]);
Pi_Prime.col(j) = P_Prime.col(i) - P_Prime.col(adj_list[i][j]);
}
Si = Pi * Di * Pi_Prime.transpose();
Matrix3f Ui;
Vector3f Wi;
Matrix3f Vi;
wunderSVD3x3(Si, Ui, Wi, Vi);
R[i] = Vi * Ui.transpose();
if (R[i].determinant() < 0)
std::cout << "determinant is negative!" << std::endl;
}
}
示例4: integrateFeatures
void CCubicGrids::integrateFeatures( const pcl::device::Intr& cCam_, const Matrix3f& Rw_, const Vector3f& Tw_, int nFeatureScale_,
GpuMat& pts_curr_, GpuMat& nls_curr_,
GpuMat& gpu_key_points_curr_, const GpuMat& gpu_descriptor_curr_, const GpuMat& gpu_distance_curr_, const int nEffectiveKeypoints_,
GpuMat& gpu_inliers_, const int nTotalInliers_){
using namespace btl::device;
//Note: the point cloud int cFrame_ must be transformed into world before calling it, i.e. it integrate a VMap NMap in world to the volume in world
//get VMap and NMap in world
Matrix3f tmp = Rw_;
pcl::device::Mat33& devRwCurTrans = pcl::device::device_cast<pcl::device::Mat33> ( tmp ); //device cast do the transpose implicitly because eimcmRwCur is col major by default.
//Cw = -Rw'*Tw
Eigen::Vector3f eivCwCur = - Rw_.transpose() * Tw_ ;
float3& devCwCur = pcl::device::device_cast<float3> (eivCwCur);
//locate the volume coordinate for each feature, if the feature falls outside the volume, just remove it.
cuda_nonmax_suppress_n_integrate ( _intrinsics, devRwCurTrans, devCwCur, _VolumeResolution,
_gpu_YXxZ_tsdf, _fVolumeSizeM, _fVoxelSizeM,
_fFeatureVoxelSizeM, _nFeatureScale, _vFeatureResolution, _gpu_YXxZ_vg_idx,
pts_curr_, nls_curr_, gpu_key_points_curr_, gpu_descriptor_curr_, gpu_distance_curr_, nEffectiveKeypoints_,
gpu_inliers_, nTotalInliers_, &_gpu_feature_volume_coordinate, &_gpu_counter,
&_vTotalGlobal, &_gpu_global_3d_key_points, &_gpu_global_descriptors);
PRINT(_vTotalGlobal[0]);
return;
}
示例5: degrees
/// Stabilizes mount relative to the Earth's frame
/// Inputs:
/// _roll_control_angle desired roll angle in radians,
/// _tilt_control_angle desired tilt/pitch angle in radians,
/// _pan_control_angle desired pan/yaw angle in radians
/// Outputs:
/// _roll_angle stabilized roll angle in degrees,
/// _tilt_angle stabilized tilt/pitch angle in degrees,
/// _pan_angle stabilized pan/yaw angle in degrees
void
AP_Mount::stabilize()
{
#if MNT_STABILIZE_OPTION == ENABLED
// only do the full 3D frame transform if we are doing pan control
if (_stab_pan) {
Matrix3f m; ///< holds 3 x 3 matrix, var is used as temp in calcs
Matrix3f cam; ///< Rotation matrix earth to camera. Desired camera from input.
Matrix3f gimbal_target; ///< Rotation matrix from plane to camera. Then Euler angles to the servos.
m = _ahrs.get_dcm_matrix();
m.transpose();
cam.from_euler(_roll_control_angle, _tilt_control_angle, _pan_control_angle);
gimbal_target = m * cam;
gimbal_target.to_euler(&_roll_angle, &_tilt_angle, &_pan_angle);
_roll_angle = _stab_roll ? degrees(_roll_angle) : degrees(_roll_control_angle);
_tilt_angle = _stab_tilt ? degrees(_tilt_angle) : degrees(_tilt_control_angle);
_pan_angle = degrees(_pan_angle);
} else {
// otherwise base mount roll and tilt on the ahrs
// roll/tilt attitude, plus any requested angle
_roll_angle = degrees(_roll_control_angle);
_tilt_angle = degrees(_tilt_control_angle);
_pan_angle = degrees(_pan_control_angle);
if (_stab_roll) {
_roll_angle -= degrees(_ahrs.roll);
}
if (_stab_tilt) {
_tilt_angle -= degrees(_ahrs.pitch);
}
}
#endif
}
示例6: eig
float OptSO3::linesearch(Matrix3f& R, Matrix3f& M_t_min, const Matrix3f& H,
float N, float t_max, float dt)
{
Matrix3f A = R.transpose() * H;
EigenSolver<MatrixXf> eig(A);
MatrixXcf U = eig.eigenvectors();
MatrixXcf invU = U.inverse();
VectorXcf d = eig.eigenvalues();
#ifndef NDEBUG
cout<<"A"<<endl<<A<<endl;
cout<<"U"<<endl<<U<<endl;
cout<<"d"<<endl<<d<<endl;
#endif
Matrix3f R_t_min=R;
float f_t_min = 999999.0f;
float t_min = 0.0f;
//for(int i_t =0; i_t<10; i_t++)
for(float t =0.0f; t<t_max; t+=dt)
{
//float t= ts[i_t];
VectorXcf expD = ((d*t).array().exp());
MatrixXf MN = (U*expD.asDiagonal()*invU).real();
Matrix3f R_t = R*MN.topLeftCorner(3,3);
float detR = R_t.determinant();
float maxDeviationFromI = ((R_t*R_t.transpose()
- Matrix3f::Identity()).cwiseAbs()).maxCoeff();
if ((R_t(0,0)==R_t(0,0))
&& (abs(detR-1.0f)< 1e-2)
&& (maxDeviationFromI <1e-1))
{
float f_t = evalCostFunction(R_t)/float(N);
#ifndef NDEBUG
cout<< " f_t = "<<f_t<<endl;
#endif
if (f_t_min > f_t && f_t != 0.0f)
{
R_t_min = R_t;
M_t_min = MN.topLeftCorner(3,3);
f_t_min = f_t;
t_min = t;
}
}else{
cout<<"R_t is corruputed detR="<<detR
<<"; max deviation from I="<<maxDeviationFromI
<<"; nans? "<<R_t(0,0)<<" f_t_min="<<f_t_min<<endl;
}
}
if(f_t_min == 999999.0f) return f_t_min;
// case where the MN is nans
R = R_t_min;
#ifndef NDEBUG
#endif
cout<<"R: det(R) = "<<R.determinant()<<endl<<R<<endl;
cout<< "t_min="<<t_min<<" f_t_min="<<f_t_min<<endl;
return f_t_min;
}
示例7: getLogTheta
Vector3f CalibrationNode::getLogTheta(Matrix3f R){
//Assumption R is never an Identity
float theta = acos((R.trace()-1)/2);
Matrix3f logTheta = 0.5*theta/sin(theta)*(R-R.transpose());
return Vector3f(logTheta(2,1), logTheta(0,2), logTheta(1,0));
}
示例8: getViewMatrix
Matrix4f Camera::getViewMatrix() const {
Matrix3f camCoords;
camCoords[0] = orthoNormRightDirection;
camCoords[1] = orthoNormUpDirection;
camCoords[2] = orthoNormViewDirection;
Matrix4f camTranslate = makeTranslation4f(-position);
return expand3To4(camCoords.transpose())*camTranslate;
}
示例9:
void OptSO3::updateGandH(Matrix3f& G, Matrix3f& G_prev, Matrix3f& H,
const Matrix3f& R, const Matrix3f& J, const Matrix3f& M_t_min,
bool resetH)
{
G_prev = G;
G = J - R * J.transpose() * R;
G = R*enforceSkewSymmetry(R.transpose()*G);
if(resetH)
{
H= -G;
}else{
Matrix3f tauH = H * M_t_min; //- R_prev * (RR.transpose() * N_t_min);
float gamma = ((G-G_prev)*G).trace()/(G_prev*G_prev).trace();
H = -G + gamma * tauH;
H = R*enforceSkewSymmetry(R.transpose()*H);
}
}
示例10: normals_cb
void RealtimeMF_openni::normals_cb(float* d_normals, uint8_t* haveData,
uint32_t w, uint32_t h)
{
tLog_.tic(-1); // reset all timers
int32_t nComp = 0;
float* d_nComp = this->normalExtract->d_normalsComp(nComp);
Matrix3f kRwBefore = kRw_;
tLog_.toctic(0,1);
optSO3_->updateExternalGpuNormals(d_nComp,nComp,3,0);
double residual = optSO3_->conjugateGradientCUDA(kRw_,nCGIter_);
double D_KL = optSO3_->D_KL_axisUnif();
tLog_.toctic(1,2);
{
boost::mutex::scoped_lock updateLock(this->updateModelMutex);
this->normalsImg_ = this->normalExtract->normalsImg();
if(z_.rows() != w*h) z_.resize(w*h);
this->normalExtract->uncompressCpu(optSO3_->z().data(), optSO3_->z().rows(),
z_.data(), z_.rows());
mfAxes_ = MatrixXf::Zero(3,6);
for(uint32_t k=0; k<6; ++k){
int j = k/2; // which of the rotation columns does this belong to
float sign = (- float(k%2) +0.5f)*2.0f; // sign of the axis
mfAxes_.col(k) = sign*kRw_.col(j);
}
D_KL_= D_KL;
residual_ = residual;
this->update_ = true;
updateLock.unlock();
}
tLog_.toc(2); // total time
tLog_.logCycle();
cout<<"delta rotation kRw_ = \n"<<kRwBefore*kRw_.transpose()<<endl;
cout<<"---------------------------------------------------------------------------"<<endl;
tLog_.printStats();
cout<<" residual="<<residual_<<"\t D_KL="<<D_KL_<<endl;
cout<<"---------------------------------------------------------------------------"<<endl;
fout_<<D_KL_<<" "<<residual_<<endl; fout_.flush();
//// return kRw_;
// {
// boost::mutex::scoped_lock updateLock(this->updateModelMutex);
//// pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr nDispPtr =
//// normalExtract->normalsPc();
//// nDisp_ = pcl::PointCloud<pcl::PointXYZRGB>::Ptr( new
//// pcl::PointCloud<pcl::PointXYZRGB>(*nDispPtr));
//// this->normalsImg_ = this->normalExtract->normalsImg();
// this->update_ = true;
// }
};
示例11: render
void ModelRender::render(WorldGraphics *world, const Environment *envi, const Matrix4f &mvp, unsigned int)
{
if(!world->model.isVisible()) return;
program.bind();
Matrix4f mat=mvp;
Matrix4f nmat;
Matrix3f mv;
Model * tmp;
int count;
Model ** list=world->model.renderList(count);
for(int i=0;i<count;i++)
{
tmp=list[i];
mat=tmp->getMatrix()*mvp;
nmat=tmp->getMatrix();
nmat.inverse();
mv[0]=nmat[0];
mv[1]=nmat[1];
mv[2]=nmat[2];
mv[3]=nmat[4];
mv[4]=nmat[5];
mv[5]=nmat[6];
mv[6]=nmat[8];
mv[7]=nmat[9];
mv[8]=nmat[10];
mv.transpose();
if(tmp==world->model.hightlighted())
program.uniform(uniform_selected,true);
else
program.uniform(uniform_selected,false);
program.uniformMatrix(uniform_mv,mv);
program.uniformMatrix(uniform_mvp,mat);
program.uniformMatrix(uniform_model,tmp->getMatrix());
ModelMesh * mesh=tmp->getMesh();
render(mesh);
}
program.release();
}
示例12: render
void ModelRender::render(const Matrix4f &mvp, unsigned int)
{
program.bind();
Matrix4f mat=mvp;
Matrix4f nmat;
Matrix3f mv;
glEnableVertexAttribArray(attribute_v_coord);
glEnableVertexAttribArray(attribute_normal);
glEnableVertexAttribArray(attribute_texcoord);
Model * tmp;
while(base->renderCount()>0)
{
tmp=base->popRender();
mat=tmp->getMatrix()*mvp;
nmat=tmp->getMatrix();
nmat.inverse();
mv[0]=nmat[0];
mv[1]=nmat[1];
mv[2]=nmat[2];
mv[3]=nmat[4];
mv[4]=nmat[5];
mv[5]=nmat[6];
mv[6]=nmat[8];
mv[7]=nmat[9];
mv[8]=nmat[10];
mv.transpose();
program.uniform(uniform_selected,tmp->isSelected());
program.uniformMatrix(uniform_mvp,mat);
program.uniformMatrix(uniform_mv,mv);
renderModel(tmp);
tmp=tmp->next;
}
glDisableVertexAttribArray(attribute_v_coord);
glDisableVertexAttribArray(attribute_normal);
glDisableVertexAttribArray(attribute_texcoord);
program.unbind();
}
示例13: generateSigmaPoints
void UKFPose2D::poseSensorUpdate(const Vector3f& reading, const Matrix3f& readingCov)
{
generateSigmaPoints();
// computePoseReadings
Vector3f poseReadings[7];
for(int i = 0; i < 7; ++i)
poseReadings[i] = sigmaPoints[i];
// computeMeanOfPoseReadings
Vector3f poseReadingMean = poseReadings[0];
for(int i = 1; i < 7; ++i)
poseReadingMean += poseReadings[i];
poseReadingMean *= 1.f / 7.f;
// computeCovOfPoseReadingsAndSigmaPoints
Matrix3f poseReadingAndMeanCov = Matrix3f::Zero();
for(int i = 0; i < 3; ++i)
{
const Vector3f d1 = poseReadings[i * 2 + 1] - poseReadingMean;
poseReadingAndMeanCov += (Matrix3f() << d1 * l(0, i), d1 * l(1, i), d1 * l(2, i)).finished();
const Vector3f d2 = poseReadings[i * 2 + 2] - poseReadingMean;
poseReadingAndMeanCov += (Matrix3f() << d2 * -l(0, i), d2 * -l(1, i), d2 * -l(2, i)).finished();
}
poseReadingAndMeanCov *= 0.5f;
// computeCovOfPoseReadingsReadings
Matrix3f poseReadingCov;
const Vector3f d = poseReadings[0] - poseReadingMean;
poseReadingCov << d * d.x(), d * d.y(), d * d.z();
for(int i = 1; i < 7; ++i)
{
const Vector3f d = poseReadings[i] - poseReadingMean;
poseReadingCov += (Matrix3f() << d * d.x(), d * d.y(), d * d.z()).finished();
}
poseReadingCov *= 0.5f;
poseReadingMean.z() = Angle::normalize(poseReadingMean.z());
const Matrix3f kalmanGain = poseReadingAndMeanCov.transpose() * (poseReadingCov + readingCov).inverse();
Vector3f innovation = reading - poseReadingMean;
innovation.z() = Angle::normalize(innovation.z());
const Vector3f correction = kalmanGain * innovation;
mean += correction;
mean.z() = Angle::normalize(mean.z());
cov -= kalmanGain * poseReadingAndMeanCov;
Covariance::fixCovariance(cov);
}
示例14: degrees
/// Stabilizes mount relative to the Earth's frame
/// Inputs:
/// _roll_control_angle desired roll angle in radians,
/// _tilt_control_angle desired tilt/pitch angle in radians,
/// _pan_control_angle desired pan/yaw angle in radians
/// Outputs:
/// _roll_angle stabilized roll angle in degrees,
/// _tilt_angle stabilized tilt/pitch angle in degrees,
/// _pan_angle stabilized pan/yaw angle in degrees
void
AP_Mount::stabilize()
{
#if MNT_STABILIZE_OPTION == ENABLED
// only do the full 3D frame transform if we are doing pan control
if (_stab_pan) {
Matrix3f m; ///< holds 3 x 3 matrix, var is used as temp in calcs
Matrix3f cam; ///< Rotation matrix earth to camera. Desired camera from input.
Matrix3f gimbal_target; ///< Rotation matrix from plane to camera. Then Euler angles to the servos.
m = _ahrs.get_dcm_matrix();
m.transpose();
cam.from_euler(_roll_control_angle, _tilt_control_angle, _pan_control_angle);
gimbal_target = m * cam;
gimbal_target.to_euler(&_roll_angle, &_tilt_angle, &_pan_angle);
_roll_angle = _stab_roll ? degrees(_roll_angle) : degrees(_roll_control_angle);
_tilt_angle = _stab_tilt ? degrees(_tilt_angle) : degrees(_tilt_control_angle);
_pan_angle = degrees(_pan_angle);
} else {
// otherwise base mount roll and tilt on the ahrs
// roll/tilt attitude, plus any requested angle
_roll_angle = degrees(_roll_control_angle);
_tilt_angle = degrees(_tilt_control_angle);
_pan_angle = degrees(_pan_control_angle);
if (_stab_roll) {
_roll_angle -= degrees(_ahrs.roll);
}
if (_stab_tilt) {
_tilt_angle -= degrees(_ahrs.pitch);
}
// Add lead filter.
const Vector3f &gyro = _ahrs.get_gyro();
if (_stab_roll && _roll_stb_lead != 0.0f && fabsf(_ahrs.pitch) < M_PI/3.0f) {
// Compute rate of change of euler roll angle
float roll_rate = gyro.x + (_ahrs.sin_pitch() / _ahrs.cos_pitch()) * (gyro.y * _ahrs.sin_roll() + gyro.z * _ahrs.cos_roll());
_roll_angle -= degrees(roll_rate) * _roll_stb_lead;
}
if (_stab_tilt && _pitch_stb_lead != 0.0f) {
// Compute rate of change of euler pitch angle
float pitch_rate = _ahrs.cos_pitch() * gyro.y - _ahrs.sin_roll() * gyro.z;
_tilt_angle -= degrees(pitch_rate) * _pitch_stb_lead;
}
}
#endif
}
示例15: makeSurfRev
Surface makeSurfRev(const Curve &profile, unsigned steps)
{
Surface surface;
if (!checkFlat(profile))
{
cerr << "surfRev profile curve must be flat on xy plane." << endl;
exit(0);
}
double angle = 2*PI/steps;
Matrix3f M = Matrix3f((float)cos(angle),0,(float)sin(angle),
0,1,0,
(float)(-sin(angle)),0,(float)cos(angle));
M.transpose();
Curve c = profile;
int numPoints = c.size();
for(unsigned s=0;s<steps;s++){
Curve newc;
for (unsigned i=0;i<numPoints;i++){
CurvePoint cp = c[i];
surface.VV.push_back(cp.V);
surface.VN.push_back(-cp.N);
Vector3f newV = M*cp.V;
Vector3f newN = M*cp.N;
newN.normalize();
struct CurvePoint newP = {newV, cp.T,newN,cp.B};
newc.push_back(newP);
}
c = newc;
newc.clear();
}
int another;
for(unsigned s=0;s<steps;s++){
if(s==steps-1){
another=0;
}else{
another = s+1;
}
for(unsigned i=0;i<numPoints-1;i++){
surface.VF.push_back(Tup3u(s*numPoints+i,another*numPoints+i,another*numPoints+i+1));
surface.VF.push_back(Tup3u(s*numPoints+i,another*numPoints+i+1,s*numPoints+i+1));
}
}
return surface;
}