[[TableOfContents]] === 개요 === 일시 : 2003년 3월 17일 월요일 8시 장소 : 7층 PC실 - 세미나실 === 내용 === PPT파일: Upload:CGseminar3.zip === 숙제 === * 벡터 클래스 만들기 || 윤정수 || Upload:mathLib.zip 아직 제작중 역행렬은 어찌 구하징.. ㅡㅡ;; || || 강인수 || [http://zeropage.org/wiki/moin.cgi/_5bLovely_5dboy_5e_5f_5e_2f3DLibrary 옛날에 만들어놓은거] || || 박경태 || 기권. C# struct형으로 만들어보려다가 생고생만 함. 해보기는 했어엽.. || * 창의 프로그램(nehe OpenGL tutorial 10번정도면 괜찮을듯 하군요..^^) || 박경태 || Upload:OpenGLATL03_Pkt.zip ATL(??) 컴파일후 ATLTest.htm를 실행 || || 김창성 || Upload:world.zip 음... || === 참고 === 최태호의 벡터 클래스 입니다. 참고 하세요. {{{~cpp # include "math.h" /////////////////////////////////////////////////////////////////////// //CGX_Vector # define DG 4 # define EPSILON 0.000001 # define GX_V_E_MULT(AA,B,C){AA[0]=B[0]*C[0]; AA[1]=B[1]*C[1]; AA[2]=B[2]*C[2]; AA[3]=1;} # define M_PI 3.141592 template class CGX_Vector { public: T e[DG]; public: CGX_Vector(); CGX_Vector operator+(CGX_Vector in); CGX_Vector operator+(T* in); CGX_Vector operator-(CGX_Vector in); CGX_Vector operator-(T* in); CGX_Vector operator*(T in); CGX_Vector operator/(T in); void operator=(CGX_Vector in); void operator=(T* in); T& operator[](int in); CGX_Vector operator*(CGX_Vector in);//cross product T operator^(CGX_Vector in);//dot product CGX_Vector Normalize(); CGX_Vector Clip(T v); T Max(); BOOL equal(CGX_Vector b); T* GetElement(); float Length(); friend CGX_Vector operator-(CGX_Vector in); }; ////////////////////////////////////////////////////////////////////////////// //implement template BOOL CGX_Vector::equal( CGX_Vector b) { for(int i=0;i<3;i++) if (e[i]- b[i] > EPSILON) return FALSE; return TRUE; } template T* CGX_Vector::GetElement() { return e; } template CGX_Vector::CGX_Vector() { for (int i=0;i CGX_Vector CGX_Vector::operator+(CGX_Vector in) { CGX_Vector temp; for(int count=0;count CGX_Vector CGX_Vector::operator+(T* in) { CGX_Vector temp; for(int count=0;count CGX_Vector CGX_Vector::operator-(CGX_Vector in) { CGX_Vector temp; for(int count=0;count CGX_Vector CGX_Vector::operator-(T* in) { CGX_Vector temp; for(int count=0;count CGX_Vector CGX_Vector::operator*(T in) { CGX_Vector temp; for (int i=0;i CGX_Vector CGX_Vector::operator/(T in) { CGX_Vector temp; for (int i=0;i void CGX_Vector::operator=(CGX_Vector in) { for(int count=0;count void CGX_Vector::operator=(T* in) { for(int count=0;count T& CGX_Vector::operator[](int in) { return e[in]; } template CGX_Vector CGX_Vector::operator*(CGX_Vector in) { CGX_Vector temp; temp.e[0]=e[1]*in.e[2] - e[2]*in.e[1]; temp.e[1]=e[2]*in.e[0] - e[0]*in.e[2]; temp.e[2]=e[0]*in.e[1] - e[1]*in.e[0]; return temp; } ///도트 프로덕트.. template T CGX_Vector::operator^(CGX_Vector in) { T total=0; for (int i =0;i CGX_Vector CGX_Vector::Normalize() { CGX_Vector temp; float length = (float)Length(); for (int i=0;i CGX_Vector CGX_Vector::Clip(T v) { CGX_Vector temp; for (int i=0;i v) temp.e[i]=v; else temp.e[i]=e[i]; } return temp; } template T CGX_Vector::Max() { T max=-9999999.0f; for(int i=0;imax) max= e[i]; } return max; } template float CGX_Vector::Length() { return (float)sqrt(e[0]*e[0] +e[1]*e[1]+ e[2]*e[2] ); } ///////////////////////////////// //많은 define들의 집합.. typedef CGX_Vector GX_V; }}} ---- [그래픽스세미나]