VC++2008编的一个程序,求高手帮忙调试一下,谢谢~~
#include<iostream>usingnamespace::std;classOBB{public:OBB(){into1,o2,o3,a1,a2,a3,b1,b...
#include<iostream>
using namespace::std;
class OBB
{
public:
OBB()
{
int o1,o2,o3,a1,a2,a3,b1,b2,b3,a,b,c;
int mCenter[3] = {o1,o2,o3}; //中心点坐标
int centerA[3] = {a1,a2,a3}; //底面中心坐标
int centerB[3] = {b1,b2,b3}; //顶面中心坐标
int AABBpts[8][3] = {{-a,-b,-c},{a,-b,-c},{a,b,-c},{-a,b,-c},{-a,b,-c},{a,b,-c},{a,b,c},{-a,b,c}}; //获取起重机臂的AABB包围盒的各顶点坐标
int vectorA[3] = {(mCenter[0] - centerA[0]),(mCenter[1] - centerA[1]),(mCenter[2] - centerA[2])}; //底面中心至起重机臂中心点的向量
int vectorB[3] = {(mCenter[0] - centerB[0]),(mCenter[1] - centerB[1]),(mCenter[2] - centerB[2])}; //顶面中心至起重机臂中心点的向量
int Xvector[3],Yvector[3],Zvector[3];
Xvector[3] = vectorA[3] ^ vectorB[3]; //叉乘
Yvector[3] = Xvector[3] ^ Zvector[3]; //x与z方向向量叉乘,得到y轴方向的向量
Zvector[3] = {(centerB[0]-centerA[0]),(centerB[1]-centerA[1]),(centerB[2]-centerA[2])};
//计算x、y和z方向向量的模
int mXvector[3] = sqrt(Xvector[0]*Xvector[0] + Xvector[1]*Xvector[1] + Xvector[2]*Xvector[2]);
int mYvector[3] = sqrt(Yvector[0]*Yvector[0] + Yvector[1]*Yvector[1] + Yvector[2]*Yvector[2]);
int mZvector[3] = sqrt(Zvector[0]*Zvector[0] + Zvector[1]*Zvector[1] + Zvector[2]*Zvector[2]);
int Xaxis[3],Yaxis[3],Zaxis[3];
//将x、y和z方向向量单位化
Xaxis[3] = Xvector[3]/mXvector[3];
Yaxis[3] = Yvector[3]/mYvector[3];
Zaxis[3] = Zvector[3]/mZvector[3];
}
public:
int Xaxis[3];
int Yaxis[3];
int Zaxis[3]; //三个基底坐标
~OBB();
public:
int ComputePoints()
{AABBpts[6][2]
//float AABBpts[8][3],Xaxis[3],Yaxis[3],Zaxis[3];
int mCenter[3] = {o1,o2,o3}; //中心点坐标
int AABBpts[6] = {a,b,c};
int X[3] = {1,0,0};
int Y[3] = {0,,0};
int Z[3] = {0,0, }; //空间单位坐标
int OBBpts[8][3];
//立方体上的8个顶点
OBBpts[0] = mCenter - Xaxis[3] * X * AABBpts[6][0] + Yaxis[3] * Y * AABBpts[6][1] + Zaxis[3] * Z * AABBpts[6][2];
OBBpts[1] = mCenter + Xaxis[3] * X * AABBpts[6][0] + Yaxis[3] * Y * AABBpts[6][1] + Zaxis[3] * Z * AABBpts[6][2];
OBBpts[2] = mCenter + Xaxis[3] * X * AABBpts[6][0] - Yaxis[3] * Y * AABBpts[6][1] + Zaxis[3] * Z * AABBpts[6][2];
OBBpts[3] = mCenter - Xaxis[3] * X * AABBpts[6][0] - Yaxis[3] * Y * AABBpts[6][1] + Zaxis[3] * Z * AABBpts[6][2];
OBBpts[4] = mCenter - Xaxis[3] * X * AABBpts[6][0] + Yaxis[3] * Y * AABBpts[6][1] - Zaxis[3] * Z * AABBpts[6][2];
OBBpts[5] = mCenter + Xaxis[3] * X * AABBpts[6][0] + Yaxis[3] * Y * AABBpts[6][1] - Zaxis[3] * Z * AABBpts[6][2];
OBBpts[6] = mCenter + Xaxis[3] * X * AABBpts[6][0] - Yaxis[3] * Y * AABBpts[6][1] - Zaxis[3] * Z * AABBpts[6][2];
OBBpts[7] = mCenter - Xaxis[3] * X * AABBpts[6][0] - Yaxis[3] * Y * AABBpts[6][1] - Zaxis[3] * Z * AABBpts[6][2];
for (int i = 0; i!= 8; i++)
{
for(int j = 0; j != 3; ++j)
cout<< OBBpts[i][j] << " ";
cout << endl;
}
return 0;
}
}; 展开
using namespace::std;
class OBB
{
public:
OBB()
{
int o1,o2,o3,a1,a2,a3,b1,b2,b3,a,b,c;
int mCenter[3] = {o1,o2,o3}; //中心点坐标
int centerA[3] = {a1,a2,a3}; //底面中心坐标
int centerB[3] = {b1,b2,b3}; //顶面中心坐标
int AABBpts[8][3] = {{-a,-b,-c},{a,-b,-c},{a,b,-c},{-a,b,-c},{-a,b,-c},{a,b,-c},{a,b,c},{-a,b,c}}; //获取起重机臂的AABB包围盒的各顶点坐标
int vectorA[3] = {(mCenter[0] - centerA[0]),(mCenter[1] - centerA[1]),(mCenter[2] - centerA[2])}; //底面中心至起重机臂中心点的向量
int vectorB[3] = {(mCenter[0] - centerB[0]),(mCenter[1] - centerB[1]),(mCenter[2] - centerB[2])}; //顶面中心至起重机臂中心点的向量
int Xvector[3],Yvector[3],Zvector[3];
Xvector[3] = vectorA[3] ^ vectorB[3]; //叉乘
Yvector[3] = Xvector[3] ^ Zvector[3]; //x与z方向向量叉乘,得到y轴方向的向量
Zvector[3] = {(centerB[0]-centerA[0]),(centerB[1]-centerA[1]),(centerB[2]-centerA[2])};
//计算x、y和z方向向量的模
int mXvector[3] = sqrt(Xvector[0]*Xvector[0] + Xvector[1]*Xvector[1] + Xvector[2]*Xvector[2]);
int mYvector[3] = sqrt(Yvector[0]*Yvector[0] + Yvector[1]*Yvector[1] + Yvector[2]*Yvector[2]);
int mZvector[3] = sqrt(Zvector[0]*Zvector[0] + Zvector[1]*Zvector[1] + Zvector[2]*Zvector[2]);
int Xaxis[3],Yaxis[3],Zaxis[3];
//将x、y和z方向向量单位化
Xaxis[3] = Xvector[3]/mXvector[3];
Yaxis[3] = Yvector[3]/mYvector[3];
Zaxis[3] = Zvector[3]/mZvector[3];
}
public:
int Xaxis[3];
int Yaxis[3];
int Zaxis[3]; //三个基底坐标
~OBB();
public:
int ComputePoints()
{AABBpts[6][2]
//float AABBpts[8][3],Xaxis[3],Yaxis[3],Zaxis[3];
int mCenter[3] = {o1,o2,o3}; //中心点坐标
int AABBpts[6] = {a,b,c};
int X[3] = {1,0,0};
int Y[3] = {0,,0};
int Z[3] = {0,0, }; //空间单位坐标
int OBBpts[8][3];
//立方体上的8个顶点
OBBpts[0] = mCenter - Xaxis[3] * X * AABBpts[6][0] + Yaxis[3] * Y * AABBpts[6][1] + Zaxis[3] * Z * AABBpts[6][2];
OBBpts[1] = mCenter + Xaxis[3] * X * AABBpts[6][0] + Yaxis[3] * Y * AABBpts[6][1] + Zaxis[3] * Z * AABBpts[6][2];
OBBpts[2] = mCenter + Xaxis[3] * X * AABBpts[6][0] - Yaxis[3] * Y * AABBpts[6][1] + Zaxis[3] * Z * AABBpts[6][2];
OBBpts[3] = mCenter - Xaxis[3] * X * AABBpts[6][0] - Yaxis[3] * Y * AABBpts[6][1] + Zaxis[3] * Z * AABBpts[6][2];
OBBpts[4] = mCenter - Xaxis[3] * X * AABBpts[6][0] + Yaxis[3] * Y * AABBpts[6][1] - Zaxis[3] * Z * AABBpts[6][2];
OBBpts[5] = mCenter + Xaxis[3] * X * AABBpts[6][0] + Yaxis[3] * Y * AABBpts[6][1] - Zaxis[3] * Z * AABBpts[6][2];
OBBpts[6] = mCenter + Xaxis[3] * X * AABBpts[6][0] - Yaxis[3] * Y * AABBpts[6][1] - Zaxis[3] * Z * AABBpts[6][2];
OBBpts[7] = mCenter - Xaxis[3] * X * AABBpts[6][0] - Yaxis[3] * Y * AABBpts[6][1] - Zaxis[3] * Z * AABBpts[6][2];
for (int i = 0; i!= 8; i++)
{
for(int j = 0; j != 3; ++j)
cout<< OBBpts[i][j] << " ";
cout << endl;
}
return 0;
}
}; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询