Source

papl_yaobi / src / PaplYaobi.ml

(*
  Copyright (c) 2012 Anders Lau Olsen.
  See LICENSE file for terms and conditions.
*)

type t

external caml_yaobi_build :
  float array -> int -> t = "caml_yaobi_build"

external caml_yaobi_in_collision :
  float array -> t ->
  float array -> t ->
  bool = "caml_yaobi_in_collision"

type geom_t = PaplVector.V3D.triangle_geom_t

type transform_t = float array

let build triangles =
  let buf = Array.make (9 * Array.length triangles) 0. in
  let write_vertex p (x, y, z) =
    buf.(p + 0) <- x;
    buf.(p + 1) <- y;
    buf.(p + 2) <- z
  in
  let write_triangle p (v0, v1, v2) =
    write_vertex (p + 0) v0;
    write_vertex (p + 3) v1;
    write_vertex (p + 6) v2
  in
  let () =
    Array.iteri
      (fun i t -> write_triangle (9 * i) t)
      triangles
  in
    caml_yaobi_build buf (Array.length buf)

let to_transform = PaplTransform.SE3.to_array

let in_collision ta a tb b =
  caml_yaobi_in_collision ta a tb b

module V2D = struct
  module SE = PaplTransform.SE2
  module SO = PaplTransform.SO2

  let to_transform t =
    let ((x, y), rot) = SE.get t in
    let a = SO.angle rot in
    let ca = cos a in
    let sa = sin a in
      [| ca; -.sa; 0.; x;
         sa; ca; 0.; y;
         0.; 0.; 1.; 0. |]
end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.