# typed: strict
# frozen_string_literal: true

module Stats
  class SquareRootAxis < Axis
    sig { override.params(value: Float).returns(Float) }
    def normalize(value)
      min_sqrt = Math.sqrt(min)
      max_sqrt = Math.sqrt(max)
      value_sqrt = Math.sqrt(value)
      value_normalized = (value_sqrt - min_sqrt) / (max_sqrt - min_sqrt)
      value_normalized
    end

    sig { override.params(value: Float).returns(Float) }
    def denormalize(value)
      min_sqrt = Math.sqrt(min)
      max_sqrt = Math.sqrt(max)
      value_denormalized = value * (max_sqrt - min_sqrt) + min_sqrt
      value_denormalized * value_denormalized
    end
  end
end
