小さな 3d ベクター クラスを作成しました。特に、2 つの関数を作成しました。1 つはベクトルを回転するためのもので、もう 1 つはベクトル自体の回転されたコピーを返すためのものです。だから私はfollowigを持っています:
Vector Vector::Rotate(const double angle, Vector& axis) const {
Vector b=*this;
b.Rotate(angle,axis);
return (b);
}
void Vector::Rotate(const double angle, Vector & axis) {
/* let's promote this vector to a quaternion */
Quaternion V (0,*this);
/* quaternion describing the rotation */
Quaternion q (cos(angle/2),axis*sin(angle/2));
/* actual rotation */
*this = (q*V*q.conjugate()).Vec();
}
今、私がこのようなものを書くとき:
vector2 = vector1.Rotate(rbo::M_PUCKER,i);
次のエラーが表示されます。これらのオペランドに一致する演算子 "=" はありません。オペランドの種類は次のとおりです。Vector = void
私はコンパイラが私が何を望んでいるかを理解することを期待しています.なぜ彼はベクトルを返す他のバージョンではなく void バージョンを選択するのですか? さらに、私が行った方法で同じ関数のより多くのバージョンを書くことは良い習慣ですか?