9 #define MIN(a,b) ((a)<(b)?(a):(b))
10 #define MAX(a,b) ((a)>(b)?(a):(b))
15 #define Infinity HUGE_VAL
17 //! Standard operators and useful methods for 3d vectors
18 //! Fill in the missing parts in Vec3f.cxx
23 Vec3f(float x, float y, float z);
27 Vec3f(const Vec3f& o);
28 Vec3f& operator=(const Vec3f& o);
31 float operator|(const Vec3f& o) const;
32 float dot(const Vec3f& o) const;
35 Vec3f operator%(const Vec3f& o) const;
36 Vec3f cross(const Vec3f& o) const;
40 //! length of a vector
43 //! (self-)multiply with scalar
44 Vec3f operator*(const float t) const;
45 Vec3f& operator*=(const float t);
47 //! (self-)division by scalar
48 Vec3f operator/(const float t) const;
49 Vec3f& operator/=(const float t);
51 //! vector (self-)addition
52 Vec3f operator+(const Vec3f& o) const;
53 Vec3f& operator+=(const Vec3f& o);
55 //! vector (self-)subtraction
56 Vec3f operator-(const Vec3f& o) const;
57 Vec3f& operator-=(const Vec3f& o);
59 //! component-wise multiplication of two vectors
60 Vec3f operator*(const Vec3f& o) const;
61 Vec3f& operator*=(const Vec3f& o);
63 //! component-wise division of two vectors
64 Vec3f operator/(const Vec3f& o) const;
65 Vec3f& operator/=(const Vec3f& o);
67 //! element access functions ( read-only and read-write )
68 float operator[](unsigned int i) const;
69 float& operator[](unsigned int i);
71 //! clamp each element to [0,1]
77 inline std::ostream& operator<<(std::ostream& o, const Vec3f& v)
79 o << "(" << v[0] << "," << v[1] << "," << v[2] << ")";