public static double[,] Divide(double[,] matrix, double scalar) { if (scalar.AboutEqual(0, 1.0e-10)) { throw new Exception(); } for (int i = 0; i < matrix.RowCount(); i++) { for (int j = 0; j < matrix.ColumnCount(); j++) { matrix[i, j] /= scalar; } } return(matrix); }
public static (double, double, double) RgbToHsv(double r, double g, double b) { double delta, min; double h = 0.0, s, v; min = Math.Min(Math.Min(r, g), b); v = Math.Max(Math.Max(r, g), b); delta = v - min; if (v <= 0.12) { // reduce saturation for low value colors s = ColorMath.LinearInterpolation(v, 0.005, 0.12, 0, delta / v); } else { s = delta / v; } if (s <= 0.001) { h = 0.0; } else { if (r.AboutEqual(v)) { h = (g - b) / delta; } else if (g.AboutEqual(v)) { h = 2.0 + (b - r) / delta; } else if (b.AboutEqual(v)) { h = 4.0 + (r - g) / delta; } h *= 60.0; if (h < 0.0) { h = h + 360.0; } } return(h, s, v); }
public bool Equals(AngleInterval shadow) { return(_from.AboutEqual(shadow._from) && _to.AboutEqual(shadow._to) && _full == shadow._full); }