1. Barry Schwartz
  2. caml2geom

Source

caml2geom / test1.ml

open Caml2geom
open Printf

(*-----------------------------------------------------------------------*)

let _ = printf "Coord.epsilon = %f\n" (Coord.epsilon) ;;
let _ = printf "Coord.infinity () = %f\n" (Coord.infinity ()) ;;
let _ = printf "Coord.are_near 4.00 4.09 = %B\n" (Coord.are_near 4.00 4.09) ;;
let _ = printf "Coord.are_near_eps 0.1 4.00 4.09 = %B\n" (Coord.are_near_eps 0.1 4.00 4.09);;
let _ = printf "Coord.rel_error_bound 4.00 4.09 = %B\n" (Coord.rel_error_bound 4.00 4.09) ;;
let _ = printf "Coord.rel_error_bound_eps 0.1 4.00 4.09 = %B\n" (Coord.rel_error_bound_eps 0.1 4.00 4.09);;

(*-----------------------------------------------------------------------*)

let c = Coord.epsilon

let p = Point.copy (Point.make 0. 0.) ;;
Point.set_coord p 1 50. ;;
let _ = printf "(%f,%f) %f\n" (Point.coord p 0) (Point.coord (Point.copy p) 1) (Point.length p);;
Point.set_coord p 0 10. ;;
let _ = printf "(%f,%f) %f\n" (Point.coord p 0) (Point.coord (Point.copy p) 1) (Point.length p);;
Point.normalize p ;;
let _ = printf "(%f,%f) %f\n" (Point.coord p 0) (Point.coord (Point.copy p) 1) (Point.length p);;
let p = Point.ccw p ;;
let _ = printf "(%f,%f) %f\n" (Point.coord p 0) (Point.coord (Point.copy p) 1) (Point.length p);;
let p = Point.cw p ;;
let _ = printf "(%f,%f) %f\n" (Point.coord p 0) (Point.coord (Point.copy p) 1) (Point.length p);;
let p = Point.neg p ;;
let _ = printf "(%f,%f) %f\n" (Point.coord p 0) (Point.coord (Point.copy p) 1) (Point.length p);;
Point.add_to p (Point.make 100. 100.);;
let _ = printf "(%f,%f) %f\n" (Point.coord p 0) (Point.coord (Point.copy p) 1) (Point.length p);;
Point.sub_from p (Point.make 100. 100.);;
let _ = printf "(%f,%f) %f\n" (Point.coord p 0) (Point.coord (Point.copy p) 1) (Point.length p);;
Point.mul_by p 1000.;;
let _ = printf "(%f,%f) %f\n" (Point.coord p 0) (Point.coord (Point.copy p) 1) (Point.length p);;
Point.div_by p 1000.;;
let _ = printf "(%f,%f) %f\n" (Point.coord p 0) (Point.coord (Point.copy p) 1) (Point.length p);;

let q = Point.make 0. 0.;;
let _ = printf "(%f,%f) %f\n" (Point.coord q 0) (Point.coord q 1) (Point.length q);;
Point.set q (Point.make (-50.) 50.);;
let _ = printf "(%f,%f) %f\n" (Point.coord q 0) (Point.coord q 1) (Point.length q);;

(*-----------------------------------------------------------------------*)

let bez = Bezier.make_order3 0. 10. 15. 1. ;;
let _ = printf "at0 -> %f\n" (Bezier.at0 bez) ;;
let _ = printf "at1 -> %f\n" (Bezier.at1 bez) ;;
let _ = printf "at 0.25 -> %f\n" (Bezier.value_at bez 0.25) ;;
let _ = printf "at 1/3 -> %f\n" (Bezier.value_at bez (1./.3.)) ;;
let _ = printf "at 0.5 -> %f\n" (Bezier.value_at bez 0.5) ;;
let _ = printf "at 2/3 -> %f\n" (Bezier.value_at bez (2./.3.)) ;;
let _ = printf "at 0.75 -> %f\n" (Bezier.value_at bez 0.75) ;;

(*-----------------------------------------------------------------------*)