私はOpenGLESプロジェクトのMathモジュールを作成しています。 私は、一般的なサイズC++ 11テンプレートの継承をキャストできません
template <unsigned int N>
class MatrixN {
public:
float m[N*N];
MatrixN(){}
virtual ~MatrixN(){}
void identify();
MatrixN& operator=(const MatrixN& b);
};
template <unsigned int N>
MatrixN<N> operator*(const MatrixN<N>& a, const MatrixN<N>& b);
//CPP file implementation
template<unsigned int N>
MatrixN<N> operator*(const MatrixN<N>&a, const MatrixN<N> &b) {
MatrixN<N> matrix;
for(unsigned int i = 0; i < N; i++){
for(unsigned int j = 0; j < N; j++){
matrix.m[i * N + j] = 0;
for(unsigned int z = 0; z < N; z++){
matrix.m[i * N + j] += a.m[i * N + z] * b.m[z * N + j];
}
}
}
return matrix;
}
用フロート行列を管理するためのクラスを書いて、私は3x3の行列を管理するためのサブクラスを作成し、私はこの操作を実行するのはなぜ
class Matrix3 : public MatrixN<3> {
public:
void rotateX(const float radians);
void rotateY(const float radians);
void rotateZ(const float radians);
};
//Rotations instances of Matrix3
Matrix3 rotation = this->rotation * input.rotation;
コンパイル時にこのエラーが発生しますか?
no viable conversion from 'MatrixN<3U>' to 'const Matrix3'
'operator *'は 'MatrixN'を返すので、 'Matrix3'ではありません。 –
tkausl
どのように動作するのですか? –
input.rotationはMatrixN <3>のタイプですか? – billz