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);;

(*-----------------------------------------------------------------------*)
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.