6
$\begingroup$

I want to put n equally spaced points on a circle and automatically draw chords from all points to a fixed point preferably P(0,0).

I have managed to draw the points and the circle so far with

func[n_] := Graphics[{Orange, Thickness[0.001],
{Circle[{0, 0}, 1], {Darker[Blue], PointSize@0.02, 
  Point[Table[{Cos[a], Sin[a]}, {a, 0, 2 \[Pi] - (2 \[Pi])/n, (
     2 \[Pi])/n}]]}}}];

Manipulate[func[n], {n, 3, 50}]

For n=6 it should somehow look like this

func[n_] := Graphics[{Orange, Thickness[0.001],
{{Circle[{0, 0}, 1], {Darker[Blue], PointSize@0.02, 
   Point[Table[{Cos[a], Sin[a]}, {a, 0, 2 \[Pi] - (2 \[Pi])/n, (
      2 \[Pi])/n}]]}},
 Line[{
   {Cos[(2 \[Pi])/6], Sin[(2 \[Pi])/6]}, {Cos[0], 
    Sin[0]}, {Cos[2 (2 \[Pi])/6], Sin[2 (2 \[Pi])/6]}, {Cos[0], 
    Sin[0]}, {Cos[3 (2 \[Pi])/6], Sin[3 (2 \[Pi])/6]}, {Cos[0], 
    Sin[0]}, {Cos[4 (2 \[Pi])/6], Sin[4 (2 \[Pi])/6]}, {Cos[0], 
    Sin[0]}, {Cos[5 (2 \[Pi])/6], Sin[5 (2 \[Pi])/6]}, {Cos[0], 
    Sin[0]}
   }]}}];

Manipulate[func[n], {n, 3, 50}]

Help is very much appreciated.

$\endgroup$
  • $\begingroup$ Sorry, I meant point P(1,0) $\endgroup$ – Guy Foxx Nov 16 at 8:53
5
$\begingroup$

You can also use StarGraph to get the desired picture:

Manipulate[StarGraph[n, Prolog -> Circle[], ImagePadding -> 20, PlotRange -> 1], 
  {{n, 7}, 3, 20, 1}]

enter image description here

Specify the vertex coordinates to have all the points on the circle:

Manipulate[StarGraph[n, Prolog -> Circle[], 
  VertexCoordinates -> CirclePoints[n], ImagePadding -> 20, 
  PlotRange -> 1], 
 {{n, 7}, 2, 20, 1}]

enter image description here

We can also use LocatorPane and add/delete nodes using (ALT + Click):

DynamicModule[{pts = CirclePoints[7]}, 
 LocatorPane[Dynamic[pts, (pts = Normalize /@ #) &], 
  Dynamic[StarGraph[Length @ pts, 
    VertexCoordinates -> pts, 
    ImagePadding -> 20, 
    Prolog -> Circle[], 
    GraphStyle -> "ThickEdge", 
    VertexShapeFunction -> (GraphElementData["Star"][#, #2, {1, 1}/15] &),
    PlotRange -> 1]], 
  Appearance -> None, LocatorAutoCreate -> {2, 20}]]

enter image description here

| improve this answer | |
$\endgroup$
4
$\begingroup$
chords[n_Integer?Positive] :=
 Graphics[
  {Orange,
   Circle[],
   GraphicsComplex[CirclePoints[{1, 0}, n],
    {
     Table[Line[{1, k}], {k, 2, n}],
     {Black, PointSize[Large], Point@Range[n]}
     }]
   }
  ]

Manipulate[chords[n], {{n, 6}, 1, 20, 1}]

enter image description here

| improve this answer | |
$\endgroup$
4
$\begingroup$

Since you said the fixed point should be at the origin; however, you can move it elsewhere.

Clear["Global`*"]

Manipulate[
 Graphics[{
   Circle[],
   Blue,
   Line[{pt, #}] & /@ CirclePoints[n]}],
 {{pt, {0, 0}}, Locator},
 {{n, 8}, Range[2, 20]}]

enter image description here

| improve this answer | |
$\endgroup$
1
$\begingroup$
Manipulate[
 PolarPlot[1, {t, 0, 2 Pi}, 
  PolarGridLines -> {Subdivide[0, 2 \[Pi], n], None}, 
  GridLinesStyle -> Directive[Dashed, Orange], 
  PolarAxesOrigin -> {0, 1}, PolarTicks -> {None, None}, 
  PolarAxes -> False, Axes -> False], {n, 1, 20, 1}]

enter image description here

| improve this answer | |
$\endgroup$

Your Answer

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

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