added normalize Vector3d func

This commit is contained in:
Pawel Kolodziejski 2009-07-01 19:23:58 +00:00
parent c665ef4cbe
commit bea578bf0c

View File

@ -110,6 +110,14 @@ public:
return yaw;
}
void normalize() {
float len = sqrt(dotProduct(x(), y(), z()));
if (len != 0.0f) {
float t = 1.0f / len;
set(x() * t, y() * t, y() * t);
}
}
float dotProduct(float sx, float sy, float sz) {
return x() * sx + y() * sy + z() * sz;
}