Say, I have a triangulation of an octagon:




enter image description here

Now, each diagonal in that triangulation is a diagonal of some quadrilateral. What I want to do is, when I click on one of the diagonals, it gets flipped to another diagonal of the quadrilateral in which it was inscribed initially. I have only managed to do this partially. I can flip a diagonal back and forth, using this code:

FlipDiagonal[T_List,D_List]:=Module[{TriangulationAsGraph=Graph[#]& @ T/. List -> UndirectedEdge},
 Complement[Flatten@Select[FindKClique[TriangulationAsGraph, 1 ,  Infinity, All],SubsetQ[#,D] &],D]]

Flip[L_Line, T_List,n_Integer]:=Module[{line,vpair, flip,  pts = CirclePoints[n]}, 
    line = First@L /. Line -> List ; 
     vpair =  Flatten[Position[pts,#]& /@ line] ;
      flip = FlipDiagonal[T,vpair]; 



But what I want to achieve is to be able to flip any diagonal sequentially. So I flip one diagonal, get a new triangulation, then I can flip any diagonal in that new triangulation, which will give me a new triangulation again (as long as I don't flip the same diagonal twice), etc., etc. Could someone help please?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.