Skip to content

Commit

Permalink
Merge branch 'master' of github.com:emersion/mlgrope
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed May 12, 2017
2 parents 3c4ca2a + cb846f9 commit 1c398f1
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,22 @@ let rec apply_constraints b sumForces colList linkList =
let compute_position pos colList linkList =
List.fold_left (fun acc e ->
match e with
| Ball(b) -> pos
| Ball(b) ->
let d = direction b.position pos in
b.position +: 2. *. Mlgrope.ball_radius *: d
| Rope(r) ->
if List.mem e linkList && distance pos r.position >= r.length
then r.length *: (direction r.position pos) +: r.position
else pos
| Block(bl) -> let l = Collide.polygon_circle bl.vertices pos Mlgrope.ball_radius in
let (a,b) = List.hd l in
begin
try
let (a,b) = List.hd l in
let n = Collide.circle_seg_norm a b pos in
(-2. *. Mlgrope.ball_radius *: n)
(*
List.fold_left (fun acc (a,b) ->
let n = Collide.circle_seg_norm a b pos in
acc +: (2. *. Mlgrope.ball_radius *: n)
) pos l
*)
(2. *. Mlgrope.ball_radius *: n)
with
| Failure(_) -> pos
end
| _ -> pos
) pos colList

Expand Down

0 comments on commit 1c398f1

Please sign in to comment.