Curve_sampling
Adaptive sampling of 2D curves.
Representation of a 2D sampling. This can be thought as a path, with possible "jumps" because of discontinuities or leaving the "domain". The parameter says whether the sampling comes from evaluating a function, so it makes sense to refine it, or is just a sequence of points.
val is_empty : _ t -> bool
is_empty s
returns true
iff the sampling s
contains no point.
val bounding_box : _ t -> Gg.box2
bounding_box s
returns the smallest rectangle enclosing all the points of the sampling s
.
val fn : ?n:int -> ?viewport:Gg.Box2.t -> ?init:float list ->
?init_pt:(float * float) list -> (float -> float) -> float -> float -> [ `Fn ] t
fn f a b
returns a sampling of the graph of f
on the interval [a
, b
] by evaluating f
at n
points. For the optional arguments, see param
.
val param : ?n:int -> ?viewport:Gg.Box2.t -> ?init:float list ->
?init_pt:(float * (float * float)) list ->
(float -> float * float) -> float -> float -> [ `Fn ] t
param f a b
returns a sampling of the range of f
on the interval [a
, b
] by evaluating f
at n
points (or less).
val uniform : ?n:int -> (float -> float) -> float -> float -> [ `Fn ] t
uniform f a b
returns a sampling of the graph of f
on n
equidistant points in the interval [a
, b
] (the boundaries a
and b
being always included — so n >= 2
). The resulting sampling may have less than n
points because evaluations returning points with NaN components are discarded (they split the path).
val of_path : (float * float) list -> [ `Pt ] t
Use the provided path as the sampling.
val to_list : _ t -> (float * float) list list
to_list t
return the sampling as a list of connected components of the path, each of which is given as a list of (x,y) couples.
val of_seq : ?n:int -> (float * float) Stdlib.Seq.t -> [ `Pt ] t
of_seq seq
convert the sequence of points seq
to a sampling.
val to_seq : _ t -> (float * float) Stdlib.Seq.t Stdlib.Seq.t
to_seq t
convert t
to a sequence of connected compononent.
clip t b
returns the sampling t
but clipped to the 2D box. A path that crosses the boundary will get additional nodes at the points of crossing and the part outside the bounding box will be dropped. (Thus a path entirely out of the bounding box will be removed.)
module P2 : sig ... end
Interface using Gg.p2
to represent points.
val to_channel : _ t -> Stdlib.out_channel -> unit
to_channel t ch
writes the sampling t
to the channel ch
. Each point is written as "x y" on a single line (in scientific notation). If the path is interrupted, a blank line is printed. This format is compatible with gnuplot.
val to_file : _ t -> string -> unit
to_file t fname
saves the sampling t
to the file fname
using the format described in to_channel
.
val to_latex : _ t -> ?n:int -> ?arrow:string -> ?arrow_pos:float -> ?color:Gg.color ->
string -> unit
to_latex t fname
saves the sampling t
as PGF/TikZ commands.