0
當前正在爲我的計算類在C++中的一個項目掙扎。被要求在三維空間中相對於三軸旋轉三個角度。圍繞某個軸的點的旋轉
感覺像IM還挺近的有需要的只是努力把它們放在一起的所有部件,講義是一個有點模糊的矩陣相乘:(。任何幫助表示讚賞。
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
std::cout << "Enter a number for x";
int x;
std::cin >> x;
std::cout << "Enter a number for y";
int y;
std::cin >> y;
std::cout << "Enter a number for z";
int z;
std::cin >> z;
std::cout << "Enter value for Theta";
int theta;
std::cin >> theta;
std::cout << "Enter value for Beta";
int beta;
std::cin >> beta;
std::cout << "Enter value for Gamma";
int gamma;
std::cin >> gamma;
//function allows the insertion of xyz and the three angles
{void RTheta(const double& theta, double array[3][3]);
int array =
{
{cos(theta), sin(theta), 0}, //the matrice for theta values
{sin(theta), cos(theta), 0},
{0,0,1}
};
std::cout << RTheta; //outputs value for theta
}
{
void RBeta(const double& beta, double array[3][3]);
int array =
{
{cos(beta), 0, -sin(beta)}, //the matrice for beta values
{0, 1, 0}, //outputs values for beta
{sin(beta), 0, cos(beta)}
};
std::cout << RBeta;
}
{
void RGamma(const double& gamma, double array[3][3]);
int array =
{
{1,0,0}, //the matrice for gamma
{0,cos(gamma), sin(gamma)}, //outputs values for gamma
{0, -sin(gamma), cos(gamma)}
};
std::cout << RGamma;
}
return 0;
}
如果這個問題幫助:i.imgur.com/eN5RqEe.png
看起來你正試圖在函數內定義函數。 C++不允許這樣做。在'main'之外定義這些函數。您可能會發現將它們放在'main'上方更容易,因爲您不需要前向聲明。我給你的最佳建議是[破解一本好書並閱讀正確的語法](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list)。 – user4581301
看着你的文字,它說Q21'下一個練習可以包括myArray.h'。你不包括它。另外,前面的問題討論了開發*函數*,而不是*類*;如果一個類有一個成員'void RTheta(const double&theta,double array [3] [3])',那麼類將會更有意義,因爲該簽名沒有'(x,y,z)'座標。 –
@ user4581301感謝您的答覆,即時通訊新的C + +一直在努力。只是爲了澄清你的意思是移動所有關於在主函數上方輸入x,y,theta等的位?第二部分又是如何看待的?我正在努力弄清楚如何將所有東西捆綁在一起。 –