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


C++ mat3类代码示例

本文整理汇总了C++中mat3的典型用法代码示例。如果您正苦于以下问题:C++ mat3类的具体用法?C++ mat3怎么用?C++ mat3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1:

mat3 operator +(const mat3 &_lhs, const mat3 &_rhs)
{
    mat3 m;
    for(int i = 0; i < 9; ++i)
        m.set( i, _lhs.get(i) + _rhs.get(i) );
    return m;
}
开发者ID:bhawkyard1,项目名称:Captain-Fractal-Attack-of-the-Space-Communists,代码行数:7,代码来源:mat3.cpp

示例2: fitBox

void Leaf::fitBox(const mat3 &R, vec3 &center, vec3 &halfSize)
{
	vec3 x = R.row(0);
	vec3 y = R.row(1);
	vec3 z = R.row(2);
	vec3 max(-1.0e10, -1.0e10, -1.0e10);
	vec3 min( 1.0e10,  1.0e10,  1.0e10);
	std::list<Triangle>::iterator it;
	for (it=mTriangles.begin(); it!=mTriangles.end(); it++) {
		boxSize( (*it).v1, min, max, x, y, z, TOLERANCE);
		boxSize( (*it).v2, min, max, x, y, z, TOLERANCE);
		boxSize( (*it).v3, min, max, x, y, z, TOLERANCE);
	}
	DBGP("Max: " << max);
	DBGP("Min: " << min);
	for (int i=0; i<3; i++) {
		halfSize[i] = 0.5 * (max[i] - min[i]);
	}
	DBGP("computed halfsize: " << halfSize);
	//halfSize = 0.5 * (max - min);
	center = min + halfSize;
	center = R.inverse() * center;
	//sanity check
	for (int i=0; i<3; i++) {
		if (halfSize[i] < TOLERANCE) {
			if (halfSize[i] < 0.5 * TOLERANCE) {
				DBGA("Warning: degenerate box computed");
			}
			halfSize[i] = TOLERANCE;
		}
	}
	DBGP("returned halfsize: " << halfSize);
}
开发者ID:BerkeleyAutomation,项目名称:google_goggles_project,代码行数:33,代码来源:collisionModel.cpp

示例3: removeMatrixScale

vec3 et::removeMatrixScale(mat3& mat)
{
	vec3 c0 = mat.column(0);
	vec3 c1 = mat.column(1);
	vec3 c2 = mat.column(2);

	float lengths[3] = { c0.length(), c1.length(), c2.length() };
	
	ET_ASSERT(lengths[0] > 0.0f);
	ET_ASSERT(lengths[1] > 0.0f);
	ET_ASSERT(lengths[2] > 0.0f);

	if (mat.determinant() < 0.0f)
	{
		float minValues[3] =
		{
			etMin(c0.x, etMin(c0.y, c0.z)),
			etMin(c1.x, etMin(c1.y, c1.z)),
			etMin(c2.x, etMin(c2.y, c2.z))
		};
		auto offset = std::min_element(minValues, minValues + 3) - minValues;
		lengths[offset] = -lengths[offset];
	}

	for (size_t i = 0; i < 3; ++i)
	{
		mat[0][i] /= lengths[i];
		mat[1][i] /= lengths[i];
		mat[2][i] /= lengths[i];
	}
	
	return vec3(lengths[0], lengths[1], lengths[2]);
}
开发者ID:Loki7979,项目名称:et-engine,代码行数:33,代码来源:geometry.cpp

示例4:

/*!
  Converts this quaternion to a 3x3 rotation matrix.
*/
void
Quaternion::ToRotationMatrix(mat3 &R) const
{
    double tx  = 2.0*x;
    double ty  = 2.0*y;
    double tz  = 2.0*z;
    double twx = tx*w;
    double twy = ty*w;
    double twz = tz*w;
    double txx = tx*x;
    double txy = ty*x;
    double txz = tz*x;
    double tyy = ty*y;
    double tyz = tz*y;
    double tzz = tz*z;

    R.element(0,0) = 1.0-(tyy+tzz);
    R.element(1,0) = txy-twz;
    R.element(2,0) = txz+twy;
    R.element(0,1) = txy+twz;
    R.element(1,1) = 1.0-(txx+tzz);
    R.element(2,1) = tyz-twx;
    R.element(0,2) = txz-twy;
    R.element(1,2) = tyz+twx;
    R.element(2,2) = 1.0-(txx+tyy);
}
开发者ID:HumanoidRobotics,项目名称:graspit,代码行数:29,代码来源:matvec.cpp

示例5:

void
PropertyManager::updateMat3(wxPropertyGridManager *pg, std::string label, mat3 a) {

	std::string s = label + ".Row0.x";
	pg->SetPropertyValue(wxString(s.c_str()), a.at(0,0));
	s.clear();
	s = label + ".Row0.y";
	pg->SetPropertyValue(wxString(s.c_str()), a.at(0, 1));
	s.clear();
	s = label + ".Row0.z";
	pg->SetPropertyValue(wxString(s.c_str()), a.at(0, 2));

	s.clear();
	s = label + ".Row1.x";
	pg->SetPropertyValue(wxString(s.c_str()), a.at(1, 0));
	s.clear();
	s = label + ".Row1.y";
	pg->SetPropertyValue(wxString(s.c_str()), a.at(1, 1));
	s.clear();
	s = label + ".Row1.z";
	pg->SetPropertyValue(wxString(s.c_str()), a.at(1, 2));

	s.clear();
	s = label + ".Row2.x";
	pg->SetPropertyValue(wxString(s.c_str()), a.at(2, 0));
	s.clear();
	s = label + ".Row2.y";
	pg->SetPropertyValue(wxString(s.c_str()), a.at(2, 1));
	s.clear();
	s = label + ".Row2.z";
	pg->SetPropertyValue(wxString(s.c_str()), a.at(2, 2));
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例6:

/* order.                                                              */
vec3 operator* (const vec3& v, const mat3& m)
{
	/* Multiply column one by the vector to get the new x component */
	float x = m.getColumn(0) * v;
	/* Multiply column two by the vector to get the new y component */
	float y = m.getColumn(1) * v;
	/* Multiply column three by the vector to get the new z component */
	float z = m.getColumn(2) * v;

	/* Return a new vector with the new components */
	return vec3(x, y, z);
}
开发者ID:zfergus2,项目名称:Animated_Scene_Graph_Editor,代码行数:13,代码来源:mat3.cpp

示例7: VertexShader

void Graphics::setMatrix(ConstantLocation location, const mat3& value) {
	FRHICommandListImmediate& commandList = GRHICommandList.GetImmediateCommandList();
	TShaderMapRef<FVertexShaderExample> VertexShader(GetGlobalShaderMap(ERHIFeatureLevel::SM5));
	mat3 value2 = value.Transpose();
	float floats[12];
	for (int y = 0; y < 3; ++y) {
		for (int x = 0; x < 3; ++x) {
			floats[y * 4 + x] = value.get(y, x);
		}
	}
	commandList.SetShaderParameter(VertexShader->GetVertexShader(), location.parameter.GetBufferIndex(), location.parameter.GetBaseIndex(), 4 * 12, floats);
}
开发者ID:Disar,项目名称:Kore,代码行数:12,代码来源:RHI.cpp

示例8: setOrientation

void ComponentPhysicsGeom::setOrientation(const mat3 &m)
{
	dMatrix3 r;

	const vec3 x = m.getAxisX().getNormal();
	const vec3 y = m.getAxisY().getNormal();
	const vec3 z = m.getAxisZ().getNormal();

	r[0] = x.x; r[1] = x.y; r[2] = x.z; r[3] = 0.0f;
	r[4] = y.x; r[5] = y.y; r[6] = y.z; r[7] = 0.0f;
	r[8] = z.x; r[9] = z.y; r[10]= z.z; r[11]= 0.0f;

	dGeomSetRotation(geom, r);

	getParentBlackBoard().relayMessage(MessageOrientationHasBeenSet(getOrientation()));
}
开发者ID:foxostro,项目名称:heroman,代码行数:16,代码来源:ComponentPhysicsGeom.cpp

示例9: inverse

inline mat3 inverse(mat3 const& m)
{
	scalar_t const d = 1 / m.determinant();
	if (d != 0)
	{
		scalar_t const id = 1 / d;
		return mat3(
			vec3(
				 id * (m.y.y * m.z.z - m.y.z * m.z.y),
				-id * (m.x.y * m.z.z - m.x.z * m.z.y),
				 id * (m.x.y * m.y.z - m.x.z * m.y.y)),

			 vec3(
				-id * (m.y.x * m.z.z - m.y.z * m.z.x),
				 id * (m.x.x * m.z.z - m.x.z * m.z.x),
				-id * (m.x.x * m.y.z - m.x.z * m.y.x)),

			vec3(
				 id * (m.y.x * m.z.y - m.y.y * m.z.x),
				-id * (m.x.x * m.z.y - m.x.y * m.z.x),
				 id * (m.x.x * m.y.y - m.x.y * m.y.x)));
	}
	else
	{
		return mat3::identity();
	}
}
开发者ID:redeemarr,项目名称:math,代码行数:27,代码来源:mat3.hpp

示例10: determinant

float determinant(const mat3 &_m)
{
    float a = _m.get(0,0);
    float b = _m.get(1,0);
    float c = _m.get(2,0);
    float d = _m.get(0,1);
    float e = _m.get(1,1);
    float f = _m.get(2,1);
    float g = _m.get(0,2);
    float h = _m.get(1,2);
    float i = _m.get(2,2);

    return a * (e*i - f*h) -
            b * (d*i - f*g) +
            c * (d*h - e*g);
}
开发者ID:bhawkyard1,项目名称:Captain-Fractal-Attack-of-the-Space-Communists,代码行数:16,代码来源:mat3.cpp

示例11: transpose

mat3 transpose(const mat3 &_m)
{
    mat3 r;
    for(int i = 0; i < 3; ++i)
        for(int j = 0; j < 3; ++j)
            r.set(j, i, _m.get(i, j));
		return r;
}
开发者ID:bhawkyard1,项目名称:Captain-Fractal-Attack-of-the-Space-Communists,代码行数:8,代码来源:mat3.cpp

示例12: CHECK_GL_ERROR

void ComponentPhysicsGeom::drawAxes() const
{
	CHECK_GL_ERROR();
	glPushAttrib(GL_ALL_ATTRIB_BITS);
	{
		glLineWidth(2.0f);

		const mat3 orientation = getOrientation();
		mat4 transformation(getPosition(),
			                orientation.getAxisX(),
							orientation.getAxisY(),
							orientation.getAxisZ());

		glPushMatrix();
		glMultMatrixf(transformation);

		glBegin(GL_LINES);
		glColor4fv(red);
		glVertex3fv(vec3(0,0,0));
		glVertex3fv(orientation.getAxisX());

		glColor4fv(green);
		glVertex3fv(vec3(0,0,0));
		glVertex3fv(orientation.getAxisY());

		glColor4fv(blue);
		glVertex3fv(vec3(0,0,0));
		glVertex3fv(orientation.getAxisZ());
		glEnd();

		glPopMatrix();
	}
	glPopAttrib();
	CHECK_GL_ERROR();
}
开发者ID:foxostro,项目名称:heroman,代码行数:35,代码来源:ComponentPhysicsGeom.cpp

示例13: reflect_cols

// Apply Householder reflection represented by u to column vectors of M
void reflect_cols(mat3 &M, vec3 &u)
{
    for (int i=0; i < 3; ++i) 
    {
        nv_scalar s = dot(u , M.col(i));
        for (int j=0; j < 3; ++j) 
            M(j,i) -= u[j]*s;
    }
}
开发者ID:darwin,项目名称:inferno,代码行数:10,代码来源:affine_decomp.cpp

示例14:

bool mat3::operator ==(const mat3& rhs)
{
	for(int i = 0; i < VEC_DIM; i++)
	{
		if(v[i] != rhs.getCol(i))
			return false;
	}
	return true;
}
开发者ID:solomonchild,项目名称:opengl_samples,代码行数:9,代码来源:mat3.cpp

示例15: setMatrix

void Graphics::setMatrix(ConstantLocation location, const mat3& value) {
	if (location.shaderType == -1) return;
	float floats[12];
	for (int y = 0; y < 3; ++y) {
		for (int x = 0; x < 3; ++x) {
			floats[y * 4 + x] = value.get(y, x);
		}
	}
	if (location.shaderType == 0) device->SetVertexShaderConstantF(location.reg.regindex, floats, 3);
	else device->SetPixelShaderConstantF(location.reg.regindex, floats, 3);
}
开发者ID:KTXSoftware,项目名称:Kha-haxelib,代码行数:11,代码来源:Direct3D9.cpp


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