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等的位?第二部分又是如何看待的?我正在努力弄清楚如何将所有东西捆绑在一起。 –