そこで typedef struct で Matrix3X3 という型を定義してこれを計算しようとしたところ
// error C2676: 二項演算子 '[' : 'Matrix3X3' は、この演算子または定義済の演算子に
// 適切な型への変換の定義を行いません。 (新しい動作; ヘルプを参照)
というコンパイルエラーがおきます
通常の計算もできないので、原因がわからないです
どうしたらいいのでしょうか?
環境は Visual C++ 6.0 です
typedef struct
{
double index[3][3];
}Matrix3X3;
Matrix3X3 obj[3];
//==================================================================
void func0()
{
// 画像の読み込み
GrHandle = LoadGraph( "test.jpg" );
obj[0].index[0][0] = 50;
obj[0].index[1][0] = 40;
obj[0].index[2][0] = 1;
obj[1].index[0][0] = 100;
obj[1].index[1][0] = 40;
obj[1].index[2][0] = 1;
obj[2].index[0][0] = 75;
obj[2].index[1][0] = 200;
obj[2].index[2][0] = 1;
}
// まだ理解できていない
Matrix3X3 multiplyMatrixNxM( Matrix3X3 a, Matrix3X3 b )
{
Matrix3X3 temp;
temp.index[0][0] = 0.0f;
temp.index[1][0] = 0.0f;
temp.index[2][0] = 0.0f;
for( int i = 0; i<3; i++ )
{
for( int j=0; j<3; j++ )
{
temp.index[i][0] = (a.index[i][j] * b.index[j][0] );
}
}
return temp;
}
Matrix3X3 rotate2D( Matrix3X3 start, float theta )
{
Matrix3X3 temp;
Matrix3X3 result;
// 行列を0で初期化
memset( &temp, 0, sizeof(temp) );
// 回転行列に必要な値を入力
temp.index[0][0] = cos( DegreesToRads(theta) );
temp.index[1][1] = cos( DegreesToRads(theta) );
temp.index[2][2] = 1;
temp.index[0][1] = -1 * (sin(DegreesToRads(theta)));
temp.index[1][0] = sin(DegreesToRads(theta));
// まだ、理解できていない
// result = multiplyMatrixNxM( temp, start );
// error C2676: 二項演算子 '[' : 'Matrix3X3' は、この演算子または定義済の演算子に
// 適切な型への変換の定義を行いません。 (新しい動作; ヘルプを参照)
result[0][0] = 0 * 0; // これもダメ
result[0][0] = temp.index[0][1] * start.index[0][0];
result[1][0] = temp.index[1][0] * start.index[1][0];
result[2][0] = temp.index[2][2] * start.index[2][0];
return result;
}