include/vector.h
branchpyrit
changeset 94 4c8abb8977dc
parent 93 96d65f841791
child 95 ca7d4c665531
--- a/include/vector.h	Tue May 06 09:39:58 2008 +0200
+++ b/include/vector.h	Thu May 08 09:21:25 2008 +0200
@@ -1,5 +1,6 @@
-/*
- * vector.h: Vector class with Colour alias
+/**
+ * @file  vector.h
+ * @brief Vector class with Colour alias
  *
  * This file is part of Pyrit Ray Tracer.
  *
@@ -64,7 +65,7 @@
 
 	bool operator==(const Vector &v) const { return x==v.x && y==v.y && z==v.z; };
 
-	// normalize
+	/** Normalize the vector */
 	Vector normalize()
 	{
 		const Float f = 1.0f / mag();
@@ -72,21 +73,23 @@
 		return *this;
 	};
 
-	// get normalized copy
+	/** Get normalized copy of vector */
 	friend Vector normalize(const Vector &v)
 	{
 		const Float f = 1.0f / v.mag();
 		return v * f;
 	};
 
-	// square magnitude, magnitude
+	/** Square magnitude */
 	Float mag2() const	{ return dot(*this, *this); };
+
+	/** Vector magnitude */
 	Float mag() const	{ return sqrtf(mag2()); };
 
-	// negative
+	/** Get negative vector */
 	Vector operator-() const { return Vector(-x, -y, -z); };
 
-	// accumulate
+	/** Accumulate. Useful for colors. */
 	Vector operator+=(const Vector &v)
 	{
 #ifdef NO_SIMD
@@ -99,7 +102,7 @@
 		return *this;
 	};
 
-	// multiply
+	/** Multiply by scalar */
 	Vector operator*=(const Float &f)
 	{
 		x *= f;
@@ -108,8 +111,7 @@
 		return *this;
 	};
 
-
-	// cut
+	/** Cut with scalar */
 	Vector operator/=(const Float &f)
 	{
 		Float finv = 1.0f / f;
@@ -119,7 +121,7 @@
 		return *this;
 	};
 
-	// sum
+	/** Sum of two vectors */
 	friend Vector operator+(const Vector &a, const Vector &b)
 	{
 #ifdef NO_SIMD
@@ -129,7 +131,7 @@
 #endif
 	};
 
-	// difference
+	/** Difference of two vectors */
 	friend Vector operator-(const Vector &a, const Vector &b)
 	{
 #if defined(NO_SIMD) || defined(MSVC)
@@ -140,13 +142,13 @@
 #endif
 	};
 
-	// dot product
+	/** Dot product */
 	friend Float dot(const Vector &a, const Vector &b)
 	{
 		return a.x * b.x + a.y * b.y + a.z * b.z;
 	};
 
-	// cross product
+	/** Cross product */
 	friend Vector cross(const Vector &a, const Vector &b)
 	{
 		return Vector(a.y * b.z - a.z * b.y,
@@ -154,24 +156,26 @@
 			a.x * b.y - a.y * b.x);
 	};
 
-	// product of vector and scalar
+	/** Get vector multiplied by scalar */
 	friend Vector operator*(const Vector &v, const Float &f)
 	{
 		return Vector(f * v.x, f * v.y, f * v.z);
 	};
 
+	/** Get vector multiplied by scalar */
 	friend Vector operator*(const Float &f, const Vector &v)
 	{
 		return v * f;
 	};
 
-	// scalar division
+	/** Get vector divided by scalar */
 	friend Vector operator/(const Vector &v, const Float &f)
 	{
 		const Float finv = 1.0f / f;
 		return Vector(v.x * finv, v.y * finv, v.z * finv);
 	};
 
+	/** Get f/v, i.e. inverted vector multiplied by scalar */
 	friend Vector operator/(const Float &f, const Vector &v)
 	{
 #ifdef NO_SIMD
@@ -181,20 +185,20 @@
 #endif
 	};
 
-	// vector plus scalar
+	/** Add scalar to the vector */
 	friend Vector operator+(const Vector &v, const Float &f)
 	{
 		return Vector(v.x + f, v.y + f, v.z + f);
 	};
 
-	// vector minus scalar
+	/** Subtract scalar from the vector */
 	friend Vector operator-(const Vector &v, const Float &f)
 	{
 		return Vector(v.x - f, v.y - f, v.z - f);
 	};
 
-	// cell by cell product (only usable for colours)
-	friend Vector operator*(const Vector &a,  const Vector &b)
+	/** Cell by cell product (only useful for colors) */
+	friend Vector operator*(const Vector &a, const Vector &b)
 	{
 #ifdef NO_SIMD
 		return Vector(a.x * b.x, a.y * b.y, a.z * b.z);
@@ -203,13 +207,13 @@
 #endif
 	};
 
-	// write
+	/** Write textual representation of the vector to stream */
 	friend ostream & operator<<(ostream &st, const Vector &v)
 	{
 		return st << "(" << v.x << "," << v.y  << "," << v.z << ")";
 	};
 
-	// read
+	/** Read the vector from stream */
 	friend istream & operator>>(istream &st, Vector &v)
 	{
 		char s[10];
@@ -224,9 +228,13 @@
 	};
 };
 
+/** Colour is a alias name of Vector. */
 typedef Vector Colour;
 
 #ifndef NO_SIMD
+/**
+  * Packet of four Vectors
+  */
 class VectorPacket
 {
 public: