private static void TestxyYToXYZ(float xyY_x, float xyY_y, float xyY_Y, float expectedX, float expectedY, float expectedZ) { float x, y, z; CieXYZUtils.xyYToXYZ(xyY_x, xyY_y, xyY_Y, out x, out y, out z); Assert.That(x, Is.EqualTo(expectedX).Within(Epsilon)); Assert.That(y, Is.EqualTo(expectedY).Within(Epsilon)); Assert.That(z, Is.EqualTo(expectedZ).Within(Epsilon)); }
private static void TestXYZToxyY(float x, float y, float z, float expected_xyY_x, float expected_xyY_y, float expected_xyY_Y) { float xyY_x, xyY_y, xyY_Y; CieXYZUtils.XYZToxyY(x, y, z, out xyY_x, out xyY_y, out xyY_Y); Assert.That(xyY_x, Is.EqualTo(expected_xyY_x).Within(Epsilon)); Assert.That(xyY_y, Is.EqualTo(expected_xyY_y).Within(Epsilon)); Assert.That(xyY_Y, Is.EqualTo(expected_xyY_Y).Within(Epsilon)); }
private static void TestXYZToCieRGB(float x, float y, float z, float expectedR, float expectedG, float expectedB) { float r, g, b; CieXYZUtils.XYZToCieRGB(x, y, z, out r, out g, out b); Assert.That(r, Is.EqualTo(expectedR).Within(Epsilon)); Assert.That(g, Is.EqualTo(expectedG).Within(Epsilon)); Assert.That(b, Is.EqualTo(expectedB).Within(Epsilon)); }
private static void TestCieRGBToXYZ(float r, float g, float b, float expectedX, float expectedY, float expectedZ) { float x, y, z; CieXYZUtils.CieRGBToXYZ(r, g, b, out x, out y, out z); Assert.That(x, Is.EqualTo(expectedX).Within(Epsilon)); Assert.That(y, Is.EqualTo(expectedY).Within(Epsilon)); Assert.That(z, Is.EqualTo(expectedZ).Within(Epsilon)); }
public void XYZToCieRGB_is_inverse_of_CieRGBToXYZ() { for (float r = -1; r <= 1; r += Step) { for (float g = 0; g <= 1; g += Step) { for (float b = 0; b <= 1; b += Step) { float x, y, z; CieXYZUtils.CieRGBToXYZ(r, g, b, out x, out y, out z); TestXYZToCieRGB(x, y, z, r, g, b); } } } }
public void xyYToXYZ_is_inverse_of_XYZToxyY() { for (float x = 0; x <= 1; x += Step) { for (float y = Step; y <= 1; y += Step) { for (float z = 0; z <= 1; z += Step) { if (x == 0 && y == 0 && z == 0) { continue; } float xyY_x, xyY_y, xyY_Y; CieXYZUtils.XYZToxyY(x, y, z, out xyY_x, out xyY_y, out xyY_Y); TestxyYToXYZ(xyY_x, xyY_y, xyY_Y, x, y, z); } } } }