Module: Termin::ANSIColor::RGBColorMetricsHelpers::WeightedEuclideanDistance
- Included in:
- Termin::ANSIColor::RGBColorMetrics::CIELab::CIELabTriple, Termin::ANSIColor::RGBColorMetrics::CIEXYZ::CIEXYZTriple, Termin::ANSIColor::RGBColorMetrics::YUV::YUVTriple, Termin::ANSIColor::RGBTriple
- Defined in:
- lib/termin/ansicolor/rgb_color_metrics.rb
Instance Method Summary collapse
Instance Method Details
#weighted_euclidean_distance_to(other, weights = [ 1.0 ] * values.size) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/termin/ansicolor/rgb_color_metrics.rb', line 5 def weighted_euclidean_distance_to(other, weights = [ 1.0 ] * values.size) sum = 0.0 values.zip(other.values, weights) do |s, o, w| sum += w * (s - o) ** 2 end Math.sqrt(sum) end |