3
$\begingroup$

Can someone help me create code for a hippocrates moons on random shape with given amount of edges? I want to make something like this:

when you press button, it asks you for the amount of edges/points you want, then it adds given amount of point in random spots on a circle (R=constant) and draws shape from it. Each side of the shape has small circle on the middle with diameter of the same lenght as that side.

Heres what I managed to do so far: Triangle with adjustable sides lenght:

Button["show", 
 Print[Animate[
   Show[Graphics[{Blue, Disk[{0, b/2`}, b/2`], Blue, 
      Disk[{a/2, 0}, a/2], RGBColor[1, 1, 1], 
      Disk[{a/2, b/2`}, Sqrt[a^2 + b^2]/2], RGBColor[0, 0, 0], 
      Circle[{a/2, b/2`}, Sqrt[a^2 + b^2]/2], Red, 
      Polygon[{{0, 0}, {a, 0}, {0, b}}], RGBColor[0, 0, 0], 
      Line[{{-b/2, b/2}, {0, b/2}}], Line[{{a/2, 0}, {a/2, -a/2}}], 
      Line[{{0, 0}, {a, 0}}], Line[{{0, 0}, {0, b}}], 
      Line[{{0, b}, {a, 0}}], Thick, Line[{{a/2, b/2}, {a, 0}}], 
      Line[{{a/2, b/2}, {a/2 + Sqrt[a^2 + b^2]/2, b/2}}]}, {Axes -> 
       True, AxesStyle -> Black}], 
    AxesLabel -> {HoldForm[x], HoldForm[y]}, 
    PlotLabel -> HoldForm[Triangle], LabelStyle -> {Black},
     Frame -> Automatic], {a, 1, 5, Appearance -> "Labeled"}, {b, 1, 
    5, Appearance -> "Labeled"}, AnimationRate -> 0.5, 
   AnimationRunning -> False]], Method -> "Queued"]

I want to do something like this but for random point placement and for given amount of points (program ask u how many points you want). Animate is not required here, just the image.

I only managed to put random points on circle and I am stuck. This is the code:

f[] := Block[{u, t, r}, u = Random[] + Random[];
  t = Random[] 2 Pi;
  r = 1;
  {r Cos[t], r Sin[t]}]
a = Sort[Table[f[], {4}]]
ListPlot[a, AspectRatio -> Automatic]

Help please

$\endgroup$
2
$\begingroup$

Your request is unclear. Nevertheless, this code generates Hippocrates moons, which should serve as a start.

Manipulate[
 RegionPlot[x^2 + y^2 > 1 && (x - a)^2 + (y - b)^2 < c^2,
  {x, -3, 3}, {y, -3, 3},
  PlotPoints -> 50],
 {{a, 1}, -2, 2},
 {{b, 1}, -2, 2},
 {{c, 1}, .1, 3}]

If you sketch by hand a figure you desire, that would help us greatly.

$\endgroup$
  • $\begingroup$ Just use the code I posted for triangle - I want figure like this but with randomly generated edges and for set amount of edges. $\endgroup$ – Tsin Dec 17 '15 at 17:43

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.