Q:

Should I Include the W-component of a vector when calculating it's length or dot product?

The reason I'm asking this is because I saw an implementation which did it that way but I don't quiet understand it. I mean, usually I want to get the distance between two points in 3d space and if W is something other than 0 the result is not correct. The same when calculating lighting using the dot product.
float Vector::Length() const{
    return sqrtf(X * X + Y * Y + Z * Z + W * W);    //W necessary?
}

float Vector::Dot(const Vector& other) const{
    return X * other.X + Y * other.Y + Z * other.Z + W * other.W;
}

Edit: There are suggestions that my question is a duplicate of already existing ones. But the questions referred to are about whether you need the W component at all and for what. I know what I need it for, I'm just not sure about it's role in the operations I specified.

A:

The only reason you need to extend a vector to 4 dimensions (homogeneous coordinates, not 4-Dimensional space) is so that you can apply transforms or matrices (model, etc) to it. Unless you're explicitly making a game in a 4-Dimensional space you don't need to include the w component in the calculations you mentioned.
Indeed, as you noted, using a w different than 0 will of course yield wrong results for your typical 3D calculations.

