벡터내적외적 프로그램
-
게시물 수정 , 삭제는 로그인 필요
벡터의 내적 계산 프로그램과 외적 계산 프로그램에 대한 원리를 알고 싶습니다.
부탁드려여....
#내적계산 프로그램#
DotProduct
inline D3DVALUE DotProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
{
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
}
#외적 계산 프로그램#
CrossProduct
inline _D3DVECTOR CrossProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
{
_D3DVECTOR result;
result[0]=v1[1]*v2[2]-v1[2]*v2[1];
result[1]=v1[2]*v2[0]-v1[0]*v2[2];
result[2]=v1[0]*v2[1]-v1[1]*v2[0];
return result;
}
부탁드려여....
#내적계산 프로그램#
DotProduct
inline D3DVALUE DotProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
{
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
}
#외적 계산 프로그램#
CrossProduct
inline _D3DVECTOR CrossProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
{
_D3DVECTOR result;
result[0]=v1[1]*v2[2]-v1[2]*v2[1];
result[1]=v1[2]*v2[0]-v1[0]*v2[2];
result[2]=v1[0]*v2[1]-v1[1]*v2[0];
return result;
}