Skip to content

Instantly share code, notes, and snippets.

@akanehara
Last active August 29, 2015 14:06
Show Gist options
  • Save akanehara/d515ef67108ad3c6b942 to your computer and use it in GitHub Desktop.
Save akanehara/d515ef67108ad3c6b942 to your computer and use it in GitHub Desktop.
(* 目的: 中点 *)
(* chuten : float * float -> float * float -> float * float *)
let chuten p q =
match p with
(px, py) ->
match q with
(qx, qy) ->
((px +. qx) /. 2., (py +. qy) /. 2.)
(* テスト *)
let chuten1 = chuten (1., 1.) (-1., -1.) = (0., 0.)
let chuten2 = chuten (-1., 1.) (1., -1.) = (0., 0.)
let chuten3 = chuten (100., 0.) (0., 100.) = (50., 50.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment