TransWikia.com

Fortune's Algorithm (Conditional Step Size in `Manipulate`)

Mathematica Asked by Anirudh Bhashyam on May 5, 2021

I am trying to implement Fortune’s Algorithm. Here is my code so far.

generalParabola[point_] := 
  point[[1]]^2 + point[[2]]^2 - 2 y point[[2]] + y^2 - a^2)/(
  2 (point[[1]] - a));
PointsData = {{150, 200}, {250, 400}, {300, 350}};
functions = {};
For[i = 1, i <= Length[PointsData], i++, 
  AppendTo[functions, generalParabola[PointsData[[i]]]]];
anim = Manipulate[
  ContourPlot[{functions[[;; k]], x==a}, {x, -512, 512}, {y, -512, 512}, 
   AspectRatio -> 1, PerformanceGoal -> "Quality", 
   Epilog -> {Red, PointSize[Large], Point[PointsData]}], {a, 151, 
   512, 1}, {k, 1, Length[PointsData], 
   Evaluate @@ Boole[a == PointsData[[k]][[1]]]}]

I am trying to get the variable k to update with a condition so that the the ContourPlot plots the parabolas only after the sweep line has crossed the point. So, unless the sweep line crosses a point I do not want k to update hence the statement Evaluate @@ Boole[a == PointsData[[k]][[1]]]. I get the following error with this:

Manipulate::vsform: Manipulate argument {k,1,Length[PointsData],Evaluate@@Boole[a==PointsData[[k]][[1]]]} does not have the correct form for a variable specification.

Searched a lot online. It has to do something with the HoldAll attribute. Can’t seem to figure out why the expression is not evaluated. (I also tried to do something like 0/.1/;a==PointsData[[k]][[1]])

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP