Vz.Dom
Domains.
Domains describe sets of continuous or discrete values and how to inject them on the unit interval [0
; 1.
] and project them back.
Domains are also always equipped with a comparison function, a formatter and a function to select values for tick marks.
type piecewise_proj =
| Proportional
The bounds of the pieces are proportionally projected on the unit space. For example the bounds of the pieces [0.; 8.; 10.]
are mapped on [0.; 0.8; 1.]
.
| Uniform
The bounds of the pieces are uniformly projected on the unit space. For example [0.; 2.; 10.]
are mapped on [0.; 0.5; 1.]
.
The type for projections on the unit interval for piecewise continuous domains.
type kind =
| Discrete
Finite and ordered list of values.
*)| Continuous of piecewise_proj
Piecewise continuous domain.
*)The kind of domain, either discrete or continuous.
module Shape : sig ... end
Domain shaping.
val inj : 'a t -> 'a -> float
inj d v
maps value v
of the domain in the unit interval [0
; 1.
]. If clamped d
is false
the resulting value can lie outisde the unit interval. If v
cannot be mapped it maps to Float
.nan.
val proj : 'a t -> float -> 'a
inj d t
is the inverse of proj
, it maps t
back to the domain value, if possible. If clamped d
is true
t
is clamped to [0
;1.
]. If t
cannot be mapped back it maps to none d
.
val proj_extents : 'a t -> float -> 'a * 'a
inv_map d t
is the inverse of map
, but maps back to a range of the original domain. This is useful if inv_map
is a quantization of the unit interval. If it's not this returns the point range inv_map d t
.
val values : 'a t -> 'a list
values d
is the list of values defining the domain. The semantics of which depends on kind
.
val none : 'a t -> 'a
none d
is the value returned by invert map when the value cannot be mapped back.
val linear : ?nice:bool -> ?clamp:bool -> float -> float -> float t
val log : ?base:float -> ?nice:bool -> ?clamp:bool -> float -> float -> float t
val pow : ?exp:float -> ?nice:bool -> ?clamp:bool -> float -> float -> float t
val sqrt : ?nice:bool -> ?clamp:bool -> float -> float -> float t
discrete vs
is a discrete domain with values vs
. Given n
values the i
th zero-based position in the order is injected to i/n
. The projection maps any value in the interval [i/n
; (i+1)/n
[ back to i
. 1.
maps to none
which by default is the last n-1
th element.