13
$\begingroup$

I want to create a picture like this:

enter image description here

This picture was found in Regular Polygon Divisionby Diagonals.

But these codes are too old to run.

I think I can use Graphics`Mesh`FindIntersections to find all the intersection points.

lines=Line/@Tuples[CirclePoints[7],2];
pts=Graphics`Mesh`FindIntersections[lines]
Graphics[{{Thickness[0.005],lines},{Directive[Red,PointSize[0.02]],Point[pts]}}]

enter image description here

Looks it meets a bug. I need another way or try to fix it.

$\endgroup$
2
  • 1
    $\begingroup$ Indeed, there seems to be a problem with Graphics`Mesh`FindIntersections[]. In the meantime: use Subsets[] instead of Tuples[]: Line /@ Subsets[CirclePoints[7], {2}] $\endgroup$ Nov 13, 2017 at 5:33
  • $\begingroup$ Still have bug when $n$ is bigger, just try $n=8$ . $\endgroup$
    – Aster
    Nov 13, 2017 at 5:49

1 Answer 1

11
$\begingroup$

This is a brute-force solution that works in version 11.1, but not in the latest version:

lines = Line /@ Subsets[CirclePoints[7], {2}];
pts = DeleteCases[RegionIntersection @@@ Subsets[lines, {2}], _EmptyRegion];

Graphics[{lines, Directive[Red, PointSize[Large]], pts}]

intersection points on the complete graph

In 11.2, the corner points are missed:

missing points

because RegionIntersection[] apparently lost the ability to find intersections of two line segments sharing an endpoint in 11.2:

RegionIntersection[Line[{{0, 0}, {1, 0}}], Line[{{0, 0}, {0, 1}}]]
   EmptyRegion[2]

where 11.1 would give the result Point[{{0, 0}}].

$\endgroup$
3
  • 1
    $\begingroup$ Please report.. $\endgroup$
    – yode
    Nov 13, 2017 at 6:18
  • 2
    $\begingroup$ Just did.$\phantom{}$ $\endgroup$ Nov 13, 2017 at 6:20
  • 5
    $\begingroup$ For workaround, you can convert coords to numerical values. lines = N[lines]. $\endgroup$
    – halmir
    Nov 13, 2017 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.