法线的相关操作都在图中,实现部分还是大家自己练习,照着图写代码就行了。
类声明:
class Normal3 { public: Normal3(); ~Normal3(); Normal3(ldouble a); Normal3(ldouble a, ldouble b, ldouble c); Normal3(const Vector3& v); Normal3(const Normal3& n); Normal3 operator+(const Normal3& n) const; Normal3& operator+=(const Normal3& n); Vector3 operator+(const Vector3& v) const; Normal3 operator*(ldouble a) const; Normal3& operator*=(ldouble a); Normal3 operator/(ldouble f) const; Normal3& operator/=(ldouble f); Normal3 operator-() const; Normal3& operator=(const Normal3& n); void normalize(); friend Normal3 operator*(ldouble a, const Normal3& n); friend std::ostream& operator<<(std::ostream& os, const Normal3& n); friend std::istream& operator>>(std::istream& is, Normal3& n); ldouble x, y, z; };