저번의 벡터계산 클래스와 달라진것으로는, 3개의 멤버함수(메소드)가 있다.
// Y(가로)-Z(세로)평면의X축각도를이용해서정규화된벡터를구한다.
// 결과값은클래스내의멤버변수(x, y, z)값으로저장된다.
// 1사분면에서시작되는CCW가디폴트다.(상식기준)
void clVector::Angle_YZp_X_(double Sigma, bool Sigma_is_Degree, bool bCCW_is_True)
{
double A[4]={1, 1, 1, 1},
B[4][4],
C[4]={0, 0, 0, 0};
if(Sigma_is_Degree)
Sigma = Sigma * 3.141592 / 180.0 ;
x = y = z = 0.0 ;
if(bCCW_is_True)
{
B[0][0]=0; B[1][0]=0; B[2][0]=0; B[3][0]=0;
B[0][1]=0; B[1][1]=cos(Sigma); B[2][1]=0; B[3][1]=0;
B[0][2]=0; B[1][2]=0; B[2][2]=sin(Sigma); B[3][2]=0;
B[0][3]=0; B[1][3]=0; B[2][3]=0; B[3][3]=1;
}
else
{
B[0][0]=0; B[1][0]=0; B[2][0]=0; B[3][0]=0;
B[0][1]=0; B[1][1]=cos(Sigma); B[2][1]=0; B[3][1]=0;
B[0][2]=0; B[1][2]=0; B[2][2]=-sin(Sigma); B[3][2]=0;
B[0][3]=0; B[1][3]=0; B[2][3]=0; B[3][3]=1;
}
for(int i=0; i<4; i++)
for (int j=0;j<4;j++)
C[i]+=A[j]*B[j][i];
x=C[0];
y=C[1];
z=C[2];
}
void clVector::Angle_YZp_X_(clVector &vlVector, double Sigma, bool Sigma_is_Degree, bool bCCW_is_True)
{
double A[4]={vlVector.x, vlVector.y, vlVector.z, 1},
B[4][4],
C[4]={0, 0, 0, 0};
if(Sigma_is_Degree)
Sigma = Sigma * 3.141592 / 180.0 ;
x = y = z = 0.0 ;
if(bCCW_is_True)
{
B[0][0]=1; B[1][0]=0; B[2][0]=0; B[3][0]=0;
B[0][1]=0; B[1][1]=cos(Sigma); B[2][1]=0; B[3][1]=0;
B[0][2]=0; B[1][2]=0; B[2][2]=sin(Sigma); B[3][2]=0;
B[0][3]=0; B[1][3]=0; B[2][3]=0; B[3][3]=1;
}
else
{
B[0][0]=1; B[1][0]=0; B[2][0]=0; B[3][0]=0;
B[0][1]=0; B[1][1]=cos(Sigma); B[2][1]=0; B[3][1]=0;
B[0][2]=0; B[1][2]=0; B[2][2]=-sin(Sigma); B[3][2]=0;
B[0][3]=0; B[1][3]=0; B[2][3]=0; B[3][3]=1;
}
for(int i=0; i<4; i++)
for (int j=0;j<4;j++)
C[i]+=A[j]*B[j][i];
x=C[0];
y=C[1];
z=C[2];
}
// X(가로)-Z(세로)평면의Y축각도를이용해서정규화된벡터를구한다.
// 결과값은클래스내의멤버변수(x, y, z)값으로저장된다.
// 1사분면에서시작되는CCW가디폴트다.(상식기준)
void clVector::Angle_XZp_Y_(double Zeta, bool Zeta_is_Degree, bool bCCW_is_True)
{
double A[4]={1, 1, 1, 1},
B[4][4],
C[4]={0, 0, 0, 0};
x = y = z = 0.0 ;
if(Zeta_is_Degree)
Zeta = Zeta * 3.141592 / 180.0 ;
if(bCCW_is_True)
{
B[0][0]=cos(Zeta); B[1][0]=0; B[2][0]=0; B[3][0]=0;
B[0][1]=0; B[1][1]=0; B[2][1]=0; B[3][1]=0;
B[0][2]=0; B[1][2]=0; B[2][2]=sin(Zeta); B[3][2]=0;
B[0][3]=0; B[1][3]=0; B[2][3]=0; B[3][3]=1;
}
else
{
B[0][0]=cos(Zeta); B[1][0]=0; B[2][0]=0; B[3][0]=0;
B[0][1]=0; B[1][1]=0; B[2][1]=0; B[3][1]=0;
B[0][2]=0; B[1][2]=0; B[2][2]=-sin(Zeta); B[3][2]=0;
B[0][3]=0; B[1][3]=0; B[2][3]=0; B[3][3]=1;
}
for(int i=0; i<4; i++)
for (int j=0;j<4;j++)
C[i]+=A[j]*B[j][i];
x=C[0];
y=C[1];
z=C[2];
}
void clVector::Angle_XZp_Y_(clVector &vlVector, double Zeta, bool Zeta_is_Degree, bool bCCW_is_True)
{
double A[4]={vlVector.x, vlVector.y, vlVector.z, 1},
B[4][4],
C[4]={0, 0, 0, 1};
x = y = z = 0.0 ;
if(Zeta_is_Degree)
Zeta = Zeta * 3.141592 / 180.0 ;
if(bCCW_is_True)
{
B[0][0]=cos(Zeta); B[1][0]=0; B[2][0]=0; B[3][0]=0;
B[0][1]=0; B[1][1]=1; B[2][1]=0; B[3][1]=0;
B[0][2]=0; B[1][2]=0; B[2][2]=sin(Zeta); B[3][2]=0;
B[0][3]=0; B[1][3]=0; B[2][3]=0; B[3][3]=1;
}
else
{
B[0][0]=cos(Zeta); B[1][0]=0; B[2][0]=0; B[3][0]=0;
B[0][1]=0; B[1][1]=1; B[2][1]=0; B[3][1]=0;
B[0][2]=0; B[1][2]=0; B[2][2]=-sin(Zeta); B[3][2]=0;
B[0][3]=0; B[1][3]=0; B[2][3]=0; B[3][3]=1;
}
for(int i=0; i<4; i++)
for (int j=0;j<4;j++)
C[i]+=A[j]*B[j][i];
x=C[0];
y=C[1];
z=C[2];
}
// X(가로)-Y(세로)평면의Z축각도를이용해서정규화된벡터를구한다.
// 결과값은클래스내의멤버변수(x, y, z)값으로저장된다.
// 1사분면에서시작되는CCW가디폴트다.(상식기준)
void clVector::Angle_XYp_Z_(double Omega, bool Omega_is_Degree, bool bCCW_is_True)
{
double A[4]={1, 1, 1, 1},
B[4][4],
C[4]={0, 0, 0, 1};
x = y = z = 0.0 ;
if(Omega_is_Degree)
Omega = Omega * (3.141592 / 180.0) ;
if(bCCW_is_True)
{
B[0][0]=cos(Omega); B[1][0]=0; B[2][0]=0; B[3][0]=0;
B[0][1]=0; B[1][1]=sin(Omega); B[2][1]=0; B[3][1]=0;
B[0][2]=0; B[1][2]=0; B[2][2]=0; B[3][2]=0;
B[0][3]=0; B[1][3]=0; B[2][3]=0; B[3][3]=1;
}
else
{
B[0][0]=cos(Omega); B[1][0]=0; B[2][0]=0; B[3][0]=0;
B[0][1]=0; B[1][1]=-sin(Omega); B[2][1]=0; B[3][1]=0;
B[0][2]=0; B[1][2]=0; B[2][2]=0; B[3][2]=0;
B[0][3]=0; B[1][3]=0; B[2][3]=0; B[3][3]=1;
}
for(int i=0; i<4; i++)
for (int j=0;j<4;j++)
C[i]+=A[j]*B[j][i];
x=C[0];
y=C[1];
z=C[2];
}
void clVector::Angle_XYp_Z_(clVector &vlVector, double Omega, bool Omega_is_Degree, bool bCCW_is_True)
{
double A[4]={vlVector.x, vlVector.y, vlVector.z, 1},
B[4][4],
C[4]={0, 0, 0, 1};
x = y = z = 0.0 ;
if(Omega_is_Degree)
Omega = Omega * (3.141592 / 180.0) ;
if(bCCW_is_True)
{
B[0][0]=cos(Omega); B[1][0]=0; B[2][0]=0; B[3][0]=0;
B[0][1]=0; B[1][1]=sin(Omega); B[2][1]=0; B[3][1]=0;
B[0][2]=0; B[1][2]=0; B[2][2]=1; B[3][2]=0;
B[0][3]=0; B[1][3]=0; B[2][3]=0; B[3][3]=1;
}
else
{
B[0][0]=cos(Omega); B[1][0]=0; B[2][0]=0; B[3][0]=0;
B[0][1]=0; B[1][1]=-sin(Omega); B[2][1]=0; B[3][1]=0;
B[0][2]=0; B[1][2]=0; B[2][2]=1; B[3][2]=0;
B[0][3]=0; B[1][3]=0; B[2][3]=0; B[3][3]=1;
}
for(int i=0; i<4; i++)
for (int j=0;j<4;j++)
C[i]+=A[j]*B[j][i];
x=C[0];
y=C[1];
z=C[2];
}
void clVector::Angle_XYZp(double Ro_X, double Ro_Y, double Ro_Z, bool Angle_is_Degree, bool bCCW_is_True)
{
double A[4]={1, 1, 1, 1},
B[4][4],
C[4][4],
D[4][4],
F[4]={0, 0, 0, 0},
G[4]={0, 0, 0, 0},
H[4]={0, 0, 0, 0},
I[4]={0, 0, 0, 0};
x = y = z = 0.0 ;
if(Angle_is_Degree)
{
Ro_X = Ro_X * (3.141592 / 180.0) ;
Ro_Y = Ro_Y * (3.141592 / 180.0) ;
Ro_Z = Ro_Z * (3.141592 / 180.0) ;
}
if(bCCW_is_True)
{
B[0][0]=1; B[1][0]=0; B[2][0]=0; B[3][0]=0;
B[0][1]=0; B[1][1]=cos(Ro_X); B[2][1]=0; B[3][1]=0;
B[0][2]=0; B[1][2]=0; B[2][2]=sin(Ro_X); B[3][2]=0;
B[0][3]=0; B[1][3]=0; B[2][3]=0; B[3][3]=1;
C[0][0]=cos(Ro_Y); C[1][0]=0; C[2][0]=0; C[3][0]=0;
C[0][1]=0; C[1][1]=1; C[2][1]=0; C[3][1]=0;
C[0][2]=0; C[1][2]=0; C[2][2]=sin(Ro_Y); C[3][2]=0;
C[0][3]=0; C[1][3]=0; C[2][3]=0; C[3][3]=1;
D[0][0]=cos(Ro_Z); D[1][0]=0; D[2][0]=0; D[3][0]=0;
D[0][1]=0; D[1][1]=sin(Ro_Z); D[2][1]=0; D[3][1]=0;
D[0][2]=0; D[1][2]=0; D[2][2]=1; D[3][2]=0;
D[0][3]=0; D[1][3]=0; D[2][3]=0; D[3][3]=1;
}
else
{
B[0][0]=1; B[1][0]=0; B[2][0]=0; B[3][0]=0;
B[0][1]=0; B[1][1]=cos(Ro_X); B[2][1]=0; B[3][1]=0;
B[0][2]=0; B[1][2]=0; B[2][2]=-sin(Ro_X); B[3][2]=0;
B[0][3]=0; B[1][3]=0; B[2][3]=0; B[3][3]=1;
C[0][0]=cos(Ro_Y); C[1][0]=0; C[2][0]=0; C[3][0]=0;
C[0][1]=0; C[1][1]=1; C[2][1]=0; C[3][1]=0;
C[0][2]=0; C[1][2]=0; C[2][2]=-sin(Ro_Y); C[3][2]=0;
C[0][3]=0; C[1][3]=0; C[2][3]=0; C[3][3]=1;
D[0][0]=cos(Ro_Z); D[1][0]=0; D[2][0]=0; D[3][0]=0;
D[0][1]=0; D[1][1]=-sin(Ro_Z); D[2][1]=0; D[3][1]=0;
D[0][2]=0; D[1][2]=0; D[2][2]=1; D[3][2]=0;
D[0][3]=0; D[1][3]=0; D[2][3]=0; D[3][3]=1;
}
for(int i=0; i<4; i++)
for (int j=0;j<4;j++)
F[i]+=A[j]*B[j][i];
cout <<F[0] <<endl;
cout <<F[1] <<endl;
cout <<F[2] <<endl;
for(int i=0; i<4; i++)
for (int j=0;j<4;j++)
G[i]+=F[j]*C[j][i];
cout <<G[0] <<endl;
cout <<G[1] <<endl;
cout <<G[2] <<endl;
for(int i=0; i<4; i++)
for (int j=0;j<4;j++)
H[i]+=G[j]*D[j][i];
cout <<H[0] <<endl;
cout <<H[1] <<endl;
cout <<H[2] <<endl;
x=G[0];
y=G[1];
z=G[2];
}