Calculate an equally bright grey to a linear RGB colour
The easiest way to get the perceived brightness of a color is to calculate the Luma. Finding the grey color with the same luma is easy - just set all of the RGB components to the desired luma value. That works because the coefficients for calculating the luma sum up to 1.

public Vector3d get_equally_bright_grey(Vector3d color) {
    double luma = color.x * 0.299 + color.y * 0.587 + color.z * 0.114;
    return new Vector3d(luma, luma, luma);
}