include/vector.h
branchpyrit
changeset 25 b8232edee786
parent 22 76b7bd51d64a
child 28 ffe83ca074f3
--- a/include/vector.h	Wed Dec 05 18:54:23 2007 +0100
+++ b/include/vector.h	Fri Dec 07 14:56:39 2007 +0100
@@ -32,9 +32,9 @@
 	Vector3(Float ax, Float ay, Float az): x(ax), y(ay), z(az) {};
 
 	// index operator
-	Float &operator[](int index)	{ return cell[index]; };
+	const Float &operator[](int index) const { return cell[index]; };
 
-	bool operator==(Vector3 &v) { return x==v.x && y==v.y && z==v.z; };
+	bool operator==(Vector3 &v) const { return x==v.x && y==v.y && z==v.z; };
 
 	// normalize
 	Vector3 normalize()
@@ -47,18 +47,18 @@
 	}
 
 	// get normalized copy
-	Vector3 unit()
+	Vector3 unit() const
 	{
 		Vector3 u(*this);
 		return u.normalize();;
 	}
 
 	// square magnitude, magnitude
-	Float mag2()	{ return x * x + y * y + z * z; }
-	Float mag()	{ return sqrtf(mag2()); }
+	Float mag2() const	{ return x * x + y * y + z * z; }
+	Float mag() const	{ return sqrtf(mag2()); }
 
 	// negative
-	Vector3 operator-()	{ return Vector3(-x, -y, -z); }
+	Vector3 operator-() const { return Vector3(-x, -y, -z); }
 
 	// accumulate
 	Vector3 operator+=(const Vector3 &v)