大家一定要先看書,在看我的隨筆啊。不然不知道原理的。而且我是不寫教程的,只是寫筆記怕自己忘記了。

我把所有的基礎類放在了名叫geometry的文件中,包含Vector3, Normal3, Point3, Point2等
類聲明:
#include "../../Types.h"
class Point3;
class Normal3;
class Matrix;
class Vector3 {
public:
Vector3();
~Vector3();
Vector3(ldouble a);
Vector3(ldouble a, ldouble b, ldouble c);
Vector3(const Vector3& v);
Vector3(const Point3& p);
Vector3(const Normal3& n);
Vector3 operator+(const Vector3& v) const;
Vector3& operator+=(const Vector3& v);
Vector3 operator-(const Vector3& v) const;
Vector3& operator-=(const Vector3& v);
Vector3 operator*(ldouble a) const;
Vector3& operator*=(ldouble a);
Vector3 operator/(ldouble f) const;
Vector3& operator/=(ldouble f);
Vector3 operator-() const;
Vector3& operator=(const Vector3& v);
bool operator==(const Vector3& v) const;
bool operator!=(const Vector3& v) const;
ldouble length() const;
ldouble length_squared() const;
void normalize();
friend Vector3 operator*(ldouble a, const Vector3& v);
friend ldouble operator*(const Vector3& v1, const Vector3& v2);
friend Vector3 operator^(const Vector3& v1, const Vector3& v2);
friend Vector3 normalize(const Vector3& v);
friend std::ostream& operator<<(std::ostream& os, const Vector3& v);
friend std::istream& operator>>(std::istream& is, Vector3& v);
ldouble x, y, z;
};
實現部分大家就認真看書自己寫一遍,練習練習,書中已經寫明白了。
為了大家編譯不會報錯,頭文件里一定要用#ifndef ....防止重復編譯報錯,之后的每一個頭文件都需要這樣提前定義,不再重復了。

然后在cpp文件中,要包含pch.h

這些都是基礎的多文件管理和編譯知識哈,沒有通過的,自己多琢磨。我已經說到這份上了,你們肯定沒問題的。
