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


C++ Mat4f::getCol方法代码示例

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


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

示例1: evalBspline

Curve evalBspline( const vector< Vec3f >& P, unsigned steps )
{
    // Check
    if( P.size() < 4 )
    {
        cerr << "evalBspline must be called with 4 or more control points." << endl;
        exit( 0 );
    }

    cerr << "\t>>> evalBSpline has been called with the following input:" << endl;

    cerr << "\t>>> Control points (type vector< Vec3f >): "<< endl;
    for( unsigned i = 0; i < P.size(); ++i )
    {
        cerr << "\t>>> "; printTranspose(P[i]); cerr << endl;
    }

	
    cerr << "\t>>> Steps (type steps): " << steps << endl;

	// Use your evalBezier function to evaluate the B-spline.
    // Convert the input control points to suitable coordinate system.
    // See lecture notes for further instructions.
    vector<Vec3f> Pbz;

	for (int i = 0; i < P.size()-3; i++) {

		// Create the G matrix for conversion
		Mat4f G;

		for (int j = 0; j < 4; j++) {
			G.setCol(j, Vec4f(P[i+j].x, P[i+j].y, P[i+j].z, 0.0));
		}

		// Calculate the conversion matrix: G_2 = G_1 * B_1 * (B_2)^-1
		G = G * Base::bsplineBase * Base::bezierBase.inverted();

		// Detach the converted control points from the G matrix
		for (int j = 0; j < 3; j++) {
			Pbz.push_back(Vec3f(G.getCol(j)[0], G.getCol(j)[1], G.getCol(j)[2]));
		}

		// Only add the last column for the very last index
		if (i+3 == P.size()-1) {
			Pbz.push_back(Vec3f(G.getCol(3)[0], G.getCol(3)[1], G.getCol(3)[2]));
		}
	}

    return evalBezier(Pbz, steps);
}
开发者ID:Zerphed,项目名称:computer-graphics-course,代码行数:50,代码来源:curve.cpp


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