include/vector.h
branchpyrit
changeset 74 09aedbf5f95f
parent 46 6493fb65f0b1
child 78 9569e9f35374
--- a/include/vector.h	Sun Apr 20 19:27:59 2008 +0200
+++ b/include/vector.h	Mon Apr 21 08:47:36 2008 +0200
@@ -66,21 +66,21 @@
 		y *= f;
 		z *= f;
 		return *this;
-	}
+	};
 
 	// get normalized copy
 	Vector3 unit() const
 	{
 		Vector3 u(*this);
-		return u.normalize();;
-	}
+		return u.normalize();
+	};
 
 	// square magnitude, magnitude
-	Float mag2() const	{ return x * x + y * y + z * z; }
-	Float mag() const	{ return sqrtf(mag2()); }
+	Float mag2() const	{ return x * x + y * y + z * z; };
+	Float mag() const	{ return sqrtf(mag2()); };
 
 	// negative
-	Vector3 operator-() const { return Vector3(-x, -y, -z); }
+	Vector3 operator-() const { return Vector3(-x, -y, -z); };
 
 	// accumulate
 	Vector3 operator+=(const Vector3 &v)
@@ -130,24 +130,35 @@
 	friend Vector3 operator*(const Vector3 &v, const Float &f)
 	{
 		return Vector3(f * v.x, f * v.y, f * v.z);
-	}
+	};
 
 	friend Vector3 operator*(const Float &f, const Vector3 &v)
 	{
 		return v * f;
 	};
 
+	// scalar division
+	friend Vector3 operator/(const Vector3 &v, const Float &f)
+	{
+		return Vector3(v.x / f, v.y / f, v.z / f);
+	};
+
+	friend Vector3 operator/(const Float &f, const Vector3 &v)
+	{
+		return Vector3(f / v.x, f / v.y, f / v.z);
+	};
+
 	// vector plus scalar
 	friend Vector3 operator+(const Vector3 &v, const Float &f)
 	{
 		return Vector3(v.x + f, v.y + f, v.z + f);
-	}
+	};
 
 	// vector minus scalar
 	friend Vector3 operator-(const Vector3 &v, const Float &f)
 	{
 		return Vector3(v.x - f, v.y - f, v.z - f);
-	}
+	};
 
 	// cell by cell product (only usable for colours)
 	friend Vector3 operator*(const Vector3 &a,  const Vector3 &b)
@@ -159,7 +170,7 @@
 	friend ostream & operator<<(ostream &st, const Vector3 &v)
 	{
 		return st << "(" << v.x << ", " << v.y  << ", " << v.z << ")";
-	}
+	};
 };
 
 typedef Vector3 Colour;