コード例 #1
0
ファイル: algebra3.cpp プロジェクト: T-Jin/glui
float &vec2::operator[](int i)
{
    if (i < VX || i > VY)
      //VEC_ERROR("vec2 [] operator: illegal access; index = " << i << '\n')
      VEC_ERROR("vec2 [] operator: illegal access" );
    return n[i];
}
コード例 #2
0
ファイル: algebra3.cpp プロジェクト: T-Jin/glui
const vec4 &mat4::operator[](int i) const
{
    if (i < VX || i > VW)
        //VEC_ERROR("mat4 [] operator: illegal access; index = " << i << '\n')
        VEC_ERROR("mat4 [] operator: illegal access" );
    return v[i];
}
コード例 #3
0
ファイル: algebra3.cpp プロジェクト: ckmarkoh/101_2_3dfinal
		mat4 mat4::inverse(void)   // Gauss-Jordan elimination with partial pivoting
		{
			mat4 a(*this),	    // As a evolves from original mat into identity
			b(identity3D());   // b evolves from identity into inverse(a)
			int i, j, i1;

			// Loop over cols of a from left to right, eliminating above and below diag
			for (j=0; j<4; j++) {   // Find largest pivot in column j among rows j..3
			i1 = j;		    // Row with largest pivot candidate
			for (i=j+1; i<4; i++)
			if (fabs(a.v[i].n[j]) > fabs(a.v[i1].n[j]))
			i1 = i;

			// Swap rows i1 and j in a and b to put pivot on diagonal
			swap(a.v[i1], a.v[j]);
			swap(b.v[i1], b.v[j]);

			// Scale row j to have a unit diagonal
			if (a.v[j].n[j]==0.)
			VEC_ERROR("mat4::inverse: singular matrix; can't invert\n");
			b.v[j] /= a.v[j].n[j];
			a.v[j] /= a.v[j].n[j];

			// Eliminate off-diagonal elems in col j of a, doing identical ops to b
			for (i=0; i<4; i++)
			if (i!=j) {
			b.v[i] -= a.v[i].n[j]*b.v[j];
			a.v[i] -= a.v[i].n[j]*a.v[j];
			}
			}
			return b;
		}
コード例 #4
0
ファイル: algebra3.cpp プロジェクト: ckmarkoh/101_2_3dfinal
		double& vec4::operator [] ( int i) {
			if (i < VX || i > VW)
			//VEC_ERROR("vec4 [] operator: illegal access; index = " << i << '\n')
			VEC_ERROR("vec4 [] operator: illegal access" );

			return n[i];
		}
コード例 #5
0
ファイル: algebra3.cpp プロジェクト: T-Jin/glui
const float &vec3::operator[](int i) const
{
    if (i < VX || i > VZ)
        //VEC_ERROR("vec3 [] operator: illegal access; index = " << i << '\n')
        VEC_ERROR("vec3 [] operator: illegal access" );

    return n[i];
}
コード例 #6
0
ファイル: algebra3.cpp プロジェクト: T-Jin/glui
vec3 &mat3::operator[](int i)
{
    if (i < VX || i > VZ)
      //VEC_ERROR("mat3 [] operator: illegal access; index = " << i << '\n')
      VEC_ERROR("mat3 [] operator: illegal access" );

    return v[i];
}