标题:求助。。讲解C++代码,关于opengl的3D魔方
取消只看楼主
miaoxiaoyao
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-5-7
结帖率:0
已结贴  问题点数:20 回复次数:0 
求助。。讲解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<<">";
}
搜索更多相关主题的帖子: namespace 不胜感激 include 小女子 
2013-05-07 07:23



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-406381-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.132220 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved