当前位置: 首页>>代码示例>>C++>>正文


C++ Matrix::rows方法代码示例

本文整理汇总了C++中yarp::sig::Matrix::rows方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::rows方法的具体用法?C++ Matrix::rows怎么用?C++ Matrix::rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yarp::sig::Matrix的用法示例。


在下文中一共展示了Matrix::rows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: appendMatrixRow

void iCubShoulderConstr::appendMatrixRow(yarp::sig::Matrix &dest,
                                         const yarp::sig::Vector &row)
{
    yarp::sig::Matrix tmp;

    // if dest is already filled with something
    if (dest.rows())
    {   
        // exit if lengths do not match     
        if (row.length()!=dest.cols())
            return;

        tmp.resize(dest.rows()+1,dest.cols());

        // copy the content of dest in temp
        for (int i=0; i<dest.rows(); i++)
            for (int j=0; j<dest.cols(); j++)
                tmp(i,j)=dest(i,j);

        // reassign dest
        dest=tmp;
    }
    else
        dest.resize(1,row.length());

    // append the last row
    for (int i=0; i<dest.cols(); i++)
        dest(dest.rows()-1,i)=row[i];
}
开发者ID:apostroph,项目名称:icub-main,代码行数:29,代码来源:iKinIpOpt.cpp

示例2: fromRotationMatrix

void Quaternion::fromRotationMatrix(const yarp::sig::Matrix &R)
{
    if ((R.rows()<3) || (R.cols()<3))
    {
        yError("fromRotationMatrix() failed, matrix should be >= 3x3");
        yAssert(R.rows() >= 3 && R.cols() >= 3);
    }

    double tr = R(0, 0) + R(1, 1) + R(2, 2);

    if (tr>0.0)
    {
        double sqtrp1 = sqrt(tr + 1.0);
        double sqtrp12 = 2.0*sqtrp1;
        internal_data[0] = 0.5*sqtrp1;
        internal_data[1] = (R(2, 1) - R(1, 2)) / sqtrp12;
        internal_data[2] = (R(0, 2) - R(2, 0)) / sqtrp12;
        internal_data[3] = (R(1, 0) - R(0, 1)) / sqtrp12;
    }
    else if ((R(1, 1)>R(0, 0)) && (R(1, 1)>R(2, 2)))
    {
        double sqdip1 = sqrt(R(1, 1) - R(0, 0) - R(2, 2) + 1.0);
        internal_data[2] = 0.5*sqdip1;

        if (sqdip1>0.0)
            sqdip1 = 0.5 / sqdip1;

        internal_data[0] = (R(0, 2) - R(2, 0))*sqdip1;
        internal_data[1] = (R(1, 0) + R(0, 1))*sqdip1;
        internal_data[3] = (R(2, 1) + R(1, 2))*sqdip1;
    }
    else if (R(2, 2)>R(0, 0))
    {
        double sqdip1 = sqrt(R(2, 2) - R(0, 0) - R(1, 1) + 1.0);
        internal_data[3] = 0.5*sqdip1;

        if (sqdip1>0.0)
            sqdip1 = 0.5 / sqdip1;

        internal_data[0] = (R(1, 0) - R(0, 1))*sqdip1;
        internal_data[1] = (R(0, 2) + R(2, 0))*sqdip1;
        internal_data[2] = (R(2, 1) + R(1, 2))*sqdip1;
    }
    else
    {
        double sqdip1 = sqrt(R(0, 0) - R(1, 1) - R(2, 2) + 1.0);
        internal_data[1] = 0.5*sqdip1;

        if (sqdip1>0.0)
            sqdip1 = 0.5 / sqdip1;

        internal_data[0] = (R(2, 1) - R(1, 2))*sqdip1;
        internal_data[2] = (R(1, 0) + R(0, 1))*sqdip1;
        internal_data[3] = (R(0, 2) + R(2, 0))*sqdip1;
    }
}
开发者ID:jgvictores,项目名称:yarp,代码行数:56,代码来源:Quaternion.cpp

示例3: setSubmatrix

bool Matrix::setSubmatrix(const yarp::sig::Matrix &m, int r, int c)
{
    if((c<0) || (c+m.cols()>ncols) || (r<0) || (r+m.rows()>nrows))
        return false;

    for(int i=0;i<m.rows();i++)
        for(int j=0;j<m.cols();j++)
            (*this)[r+i][c+j] = m(i,j);
    return true;
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:10,代码来源:Matrix.cpp

示例4: res

yarp::sig::Vector iCub::skinDynLib::toVector(yarp::sig::Matrix m)
{
    Vector res(m.rows()*m.cols(),0.0);
    
    for (int r = 0; r < m.rows(); r++)
    {
        res.setSubvector(r*m.cols(),m.getRow(r));
    }

    return res;
}
开发者ID:AbuMussabRaja,项目名称:icub-main,代码行数:11,代码来源:common.cpp

示例5: assert

void OpenSoT::SubTask::setWeight(const yarp::sig::Matrix &W)
{
    assert(W.rows() == this->getTaskSize());
    assert(W.cols() == W.rows());

    this->_W = W;
    yarp::sig::Matrix fullW = _taskPtr->getWeight();
    for(unsigned int r = 0; r < this->getTaskSize(); ++r)
        for(unsigned int c = 0; c < this->getTaskSize(); ++c)
            fullW(this->_subTaskMap.getRowsVector()[r],
                  this->_subTaskMap.getRowsVector()[c]) = this->_W(r,c);

    _taskPtr->setWeight(fullW);
}
开发者ID:bmagyar,项目名称:OpenSoT,代码行数:14,代码来源:SubTask.cpp

示例6: isEqual

    bool isEqual(const yarp::sig::Matrix& m1, const yarp::sig::Matrix& m2, double precision)
    {
        if (m1.cols() != m2.cols() || m1.rows() != m2.rows())
        {
            return false;
        }

        for (size_t i = 0; i < m1.rows(); i++)
        {
            if (!isEqual(m1.getRow(i), m2.getRow(i), precision))
            {
                return false;
            }
        }
        return true;
    }
开发者ID:claudiofantacci,项目名称:yarp,代码行数:16,代码来源:FrameTransformClientTest.cpp

示例7:

bool yarpWholeBodyModelV1::convertBasePose(const Frame &xBase, yarp::sig::Matrix & H_world_base)
{
    if( H_world_base.cols() != 4 || H_world_base.rows() != 4 )
        H_world_base.resize(4,4);
    xBase.get4x4Matrix(H_world_base.data());
    return true;
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例8: fprintf

yarp::sig::Matrix localSE3inv(const yarp::sig::Matrix &H, unsigned int verbose)
{
    if ((H.rows()<4) || (H.cols()<4))
    {
        if (verbose)
            fprintf(stderr,"localSE3inv() failed\n");

        return yarp::sig::Matrix(0,0);
    }

    yarp::sig::Matrix invH(4,4);
    yarp::sig::Vector p(3);

    yarp::sig::Matrix Rt=H.submatrix(0,2,0,2).transposed();
    p[0]=H(0,3);
    p[1]=H(1,3);
    p[2]=H(2,3);

    p=Rt*p;

    for (unsigned int i=0; i<3; i++)
        for (unsigned int j=0; j<3; j++)
            invH(i,j)=Rt(i,j);

    invH(0,3)=-p[0];
    invH(1,3)=-p[1];
    invH(2,3)=-p[2];
    invH(3,3)=1.0;

    return invH;
}
开发者ID:,项目名称:,代码行数:31,代码来源:

示例9: findIndexes

Vector BoundingBox::findIndexes(const yarp::sig::Matrix &corner_i)
{
    Vector indexes(3);
    yarp::sig::Vector point1(3); point1[0]=corner_i(0,0); point1[1]=corner_i(0,1); point1[2]=corner_i(0,2);

    int m=0;
    for (int i=0; i<3; i++)
    {
        for (int j=0; j<3; j++)
        {
            if (j<=i)
                continue;
            int index=-1;
            double minimum=10000;
            for (int t=1; t<corner_i.rows(); t++)
            {
                yarp::sig::Vector tmp(3); tmp[0]=corner_i(t,0); tmp[1]=corner_i(t,1); tmp[2]=corner_i(t,2);
                double value=norm(Helpers::extractSubVector(point1,i,j)-Helpers::extractSubVector(tmp,i,j));
                if (value<minimum)
                {
                    index=t;
                    minimum=value;
                }
            }
            indexes[m]=index;
            m+=1;
        }
    }
    return indexes;
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:30,代码来源:boundingBox.cpp

示例10: v

Vector yarp::math::dcm2ypr(const yarp::sig::Matrix &R)
{
    yAssert((R.rows() >= 3) && (R.cols() >= 3));

    Vector v(3); // yaw pitch roll

    if (R(0, 2)<1.0)
    {
        if (R(0, 2)>-1.0)
        {
            v[0] = atan2(-R(0, 1), R(0, 0));
            v[1] = asin(R(0, 2));
            v[2] = atan2(-R(1, 2), R(2, 2));
        }
        else // == -1
        {
            // Not a unique solution: psi-phi=atan2(-R12,R11)
            v[0] = 0.0;
            v[1] = -M_PI / 2.0;
            v[2] = -atan2(R(1, 0), R(1, 1));
        }
    }
    else // == +1
    {
        // Not a unique solution: psi+phi=atan2(-R12,R11)
        v[0] = 0.0;
        v[1] = M_PI / 2.0;
        v[2] = atan2(R(1, 0), R(1, 1));
    }

    return v;
}
开发者ID:jgvictores,项目名称:yarp,代码行数:32,代码来源:math.cpp

示例11: Matrix_write

bool Matrix_write(const std::string file_name, const yarp::sig::Matrix & mat)
{
    FILE * fp;
    uint32_t rows,cols;
    double elem;
    
    rows = mat.rows();
    cols = mat.cols();
    
    fp = fopen(file_name.c_str(),"wb");
    if( fp == NULL ) return false;
    
    //writing dimensions informations
    fwrite(&rows,sizeof(uint32_t),1,fp);
    fwrite(&cols,sizeof(uint32_t),1,fp);

    for(size_t i=0;i<rows;i++) {
        for(size_t j=0;j<cols;j++ ) {
            elem = mat(i,j);
            fwrite(&elem,sizeof(double),1,fp);
         }
     }
    /*
    if( gsl_matrix_fwrite(fp,(gsl_matrix*)mat.getGslMatrix()) == GSL_EFAILED ) {
        fclose(fp);
        return false;
    }*/
    fclose(fp);
    return true;
}
开发者ID:helloxss,项目名称:online-inertial-parameter-estimation,代码行数:30,代码来源:MatVetIO.cpp

示例12: idynInertia2kdlRotationalInertia

bool idynInertia2kdlRotationalInertia(const yarp::sig::Matrix & idynInertia,KDL::RotationalInertia & kdlRotationalInertia)
{
    if(idynInertia.cols() != 3 || idynInertia.rows() != 3 ) return false;
    //if(idynInertia(0,1) != idynInertia(1,0) || idynInertia(0,2) != idynInertia(2,0) || idynInertia(1,2) != idynInertia(2,1)) return false;
    kdlRotationalInertia = KDL::RotationalInertia(idynInertia(0,0),idynInertia(1,1),idynInertia(2,2),idynInertia(0,1),idynInertia(0,2),idynInertia(1,2));
    return true;
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例13: fmean

yarp::sig::Vector LinearMean::calculateMean(const yarp::sig::Matrix &x)
{
  //  std::cout << "calc mean, x size:" << x.rows() << " by " << x.cols() << ", meanHyparam size: " << meanLinearHyperparam.size() << std::endl;// fflush(stdout);
    Vector fmean(x.rows(), meanOffset);
    fmean+=x*meanLinearHyperparam;
    return fmean;
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:7,代码来源:LinearMean.cpp

示例14: KDLtoYarp

bool KDLtoYarp(const KDL::Rotation & kdlRotation, yarp::sig::Matrix & yarpMatrix3_3)
{
    if( yarpMatrix3_3.rows() != 3 || yarpMatrix3_3.cols() != 3 ) { yarpMatrix3_3.resize(3,3); }
    //Both kdl and yarp store the rotation matrix in row major order
    memcpy(yarpMatrix3_3.data(),kdlRotation.data,3*3*sizeof(double));
    return true;
}
开发者ID:robotology,项目名称:idyntree,代码行数:7,代码来源:check_iKin_export_random_chain.cpp

示例15: getVelocityState

void RobotInterface::getVelocityState(yarp::sig::Matrix& outputVelocity)
{
	outputVelocity.resize(velocityState.rows(), velocityState.cols());
	for(int i = 0; i < outputVelocity.rows(); i++)
	{
		for(int d = 0; d < outputVelocity.cols(); d++) outputVelocity(i, d) = velocityState(i, d);
	}
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:8,代码来源:robotInterface.cpp


注:本文中的yarp::sig::Matrix::rows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。