distance method

double distance(
  1. Cam16 other
)

CAM16 instances also have coordinates in the CAM16-UCS space, called J*, a*, b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16 specification, and should be used when measuring distances between colors.

Implementation

double distance(Cam16 other) {
  final dJ = jstar - other.jstar;
  final dA = astar - other.astar;
  final dB = bstar - other.bstar;
  final dEPrime = math.sqrt(dJ * dJ + dA * dA + dB * dB);
  final dE = 1.41 * math.pow(dEPrime, 0.63);
  return dE;
}