Esempio n. 1
0
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];
}
Esempio n. 2
0
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];
}
Esempio n. 3
0
		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;
		}
Esempio n. 4
0
		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];
		}
Esempio n. 5
0
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];
}
Esempio n. 6
0
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];
}