package graphv_gles2_native

  1. Overview
  2. Docs

A module for basic 2x2 (+2) matrix operations.

type t = {
  1. mutable m0 : float;
    (*

    cos a, scalex

    *)
  2. mutable m1 : float;
    (*

    sin a, shearx

    *)
  3. mutable m2 : float;
    (*

    -sin a, sheary

    *)
  4. mutable m3 : float;
    (*

    cos a, scaley

    *)
  5. mutable m4 : float;
    (*

    translatex

    *)
  6. 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 multiply : dst:t -> src:t -> unit

Standard matrix multiplication: dst = dst*src

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 identity : t -> unit
val skew_x : 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
OCaml

Innovation. Community. Security.