Module Graphv_webgl.Matrix
A module for basic 2x2 (+2) matrix operations.
type t
=
{
mutable m0 : float;
cos a, scalex
mutable m1 : float;
sin a, shearx
mutable m2 : float;
-sin a, sheary
mutable m3 : float;
cos a, scaley
mutable m4 : float;
translatex
mutable m5 : float;
translatey
}
A 2x2 transform matrix with 2 more values for translation.
m0 m1
m2 m3
m4 m5
val create : unit -> t
val copy : t -> t
val zero : t -> unit
val translate : t -> x:float -> y:float -> unit
val get_average_scale : t -> float
The formula is:
sx = sqrt(m0*m0 + m2*m2)
sy = sqrt(m1*m1 + m3*m3)
(sx + sy) * 0.5
val transform_point : t -> float -> float -> float * float
val premultiply : dst:t -> src:t -> unit
Reversed multiplication:
dst = src*dst
val scale : t -> xs:float -> ys:float -> unit
val inverse : dst:t -> src:t -> unit
val rotate : t -> angle:float -> unit
- parameter angle
Angle in radians.
val skew_y : t -> angle:float -> unit
- parameter angle
Angle in radians.
val to_3x4 : t -> float array
Returns an array:
m0 m1 0 0
m2 m3 0 0
m4 m5 1 0
val is_flipped : t -> bool
m0*m3 - m2*m1 < 0
val print : t -> unit