for (int i = 0; i < gLines.Length; i++)
            {
                // sum over weighted squared distance
                sum += (gLines[i].nearestPoint(point) - point).LengthSquared * gLines[i].weight;
            }