include/vector.h
branchpyrit
changeset 87 1081e3dd3f3e
parent 86 ce6abe0aeeae
child 91 9d66d323c354
--- a/include/vector.h	Sun Apr 27 19:56:23 2008 +0200
+++ b/include/vector.h	Sun Apr 27 22:55:17 2008 +0200
@@ -211,6 +211,8 @@
 	VectorPacket() {};
 	VectorPacket(__m128 ax, __m128 ay, __m128 az):
 		mx(ax), my(ay), mz(az) {};
+	VectorPacket(const Vector3 &v):
+		mx(_mm_set_ps1(v.x)), my(_mm_set_ps1(v.y)), mz(_mm_set_ps1(v.z)) {};
 
 	Vector3 getVector(int i) const
 	{
@@ -232,6 +234,15 @@
 		mz = _mm_mul_ps(mz, m);
 	};
 
+	// dot product
+	friend __m128 dot(const VectorPacket &a, const VectorPacket &b)
+	{
+		return _mm_add_ps(_mm_add_ps(
+			_mm_mul_ps(a.mx, b.mx),
+			_mm_mul_ps(a.my, b.my)),
+			_mm_mul_ps(a.mz, b.mz));
+	};
+
 	friend VectorPacket operator+(const VectorPacket &a, const VectorPacket &b)
 	{
 		return VectorPacket(