Commit bb53bf70 authored by Benoit Barbot's avatar Benoit Barbot
Browse files

pre simple bezier

parent db5b894d
......@@ -6,6 +6,8 @@ let (+..) (x1,y1) (x2,y2)=
let (-..) (x2,y2) (x1,y1) =
(x2-.x1),(y2-.y1)
let (~-..) (x,y) = (-.x,-.y)
let ( *..) (x1,y1) (x2,y2)=
(x1*.x2) +. (y1*.y2)
......@@ -250,12 +252,12 @@ module Circle =
ctx##stroke
let is_over tos mouse_pos ~thick (spos,control,epos) =
let sspos = tos spos
and scontrol = tos control
and sepos = tos epos in
let aA = sspos +.. (mult (-2.0) scontrol) +.. sepos in
let bB = mult 2.0 (scontrol -.. sspos) in
let cC = sspos -..mouse_pos in
let p0 = tos spos
and p1 = tos control
and p2 = tos epos in
let aA = p2 -.. (mult 2.0 p1) +.. p0 in
let bB = (mult 2.0 p1) -.. (mult 2.0 p0) in
let cC = p0 -..mouse_pos in
let delta = (vect_prod bB bB) -.. (mult 4.0 (vect_prod aA cC)) in
if fst delta >= 0.0 && snd delta >= 0.0 then
let eps x y = x>= 0.0 && x<= 1.0 && abs_float (x-.y) <= thick/.100. in
......@@ -287,10 +289,10 @@ module Circle =
and p1 = tos control1
and p2 = tos control2
and p3 = tos epos in
let aA = sspos +.. (mult (-2.0) scontrol) +.. sepos
and bB = mult 2.0 (scontrol -.. sspos)
and cC = sspos -..mouse_pos
and dD = 0 in
let aA = p3 -.. (mult 3.0 p2) +.. (mult 3.0 p1) -..p0
and bB = (mult 3.0 p2) -.. (mult 6.0 p1) +.. (mult 3.0 p0)
and cC = (mult 3.0 p1) -.. (mult 3.0 p0)
and dD = p0 -.. mouse_pos in
let delta = (vect_prod bB bB) -.. (mult 4.0 (vect_prod aA cC)) in
if fst delta >= 0.0 && snd delta >= 0.0 then
let eps x y = x>= 0.0 && x<= 1.0 && abs_float (x-.y) <= thick/.100. in
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment