求助。。讲解C++代码,关于opengl的3D魔方
小女在做毕业设计,遇到了难题,现在有代码了,可是完全看不懂,求哪位大神帮帮忙来讲解一下,QQ1786121067,小女子在此不胜感激。离答辩日子越来越近了,心里着实忐忑。这里贴出一小部分代码,哪位大神哥哥有时间的有兴趣的就来Q我一下吧,全天在线等。#include"Vector.h"
#include<iostream>
using namespace std;
CVector::CVector()
{
x=0.0;
y=0.0;
z=0.0;
}
CVector::CVector(GLfloat x,GLfloat y,GLfloat z)
{
this->x=x;
this->y=y;
this->z=z;
}
CVector::~CVector()
{
}
CVector& CVector::operator=(const CVector& vector)
{
this->x=vector.x;
this->y=vector.y;
this->z=vector.z;
return *this;
}
CVector CVector::operator+(const CVector& vector)
{
return CVector(this->x+vector.x,this->y+vector.y,this->z+vector.z);
}
CVector CVector::operator-(const CVector& vector)
{
return CVector(this->x-vector.x,this->y-vector.y,this->z-vector.z);
}
CVector CVector::operator*(const CVector& vector)
{
GLfloat x,y,z;
x=this->y*vector.z-this->z*vector.y;
y=this->z*vector.x-this->x*vector.z;
z=this->x*vector.y-this->y*vector.x;
return CVector(x,y,z);
}
CVector CVector::operator*(GLfloat radius)
{
return CVector(this->x*radius,this->y*radius,this->z*radius);
}
CVector& CVector::operator*=(GLfloat radius)
{
this->x*=radius;
this->y*=radius;
this->z*=radius;
return *this;
}
CVector& CVector::operator-=(const CVector& vector)
{
this->x-=vector.x;
this->y-=vector.y;
this->z-=vector.z;
return *this;
}
CVector& CVector::operator+=(const CVector& vector)
{
this->x+=vector.x;
this->y+=vector.y;
this->z+=vector.z;
return *this;
}
std::ostream& operator<<(std::ostream& os,const CVector& vector)
{
return os<<"<"<<vector.x<<","<<vector.y<<","<<vector.z<<">";
}