Skip to main content
added 156 characters in body
Source Link
Niki Estner
  • 36.4k
  • 3
  • 92
  • 156

I'm not sure which points you really want, so this is a stab in the dark: You could "walk around" the inner resp. outer circle, and pick the closest point in pts to every point on each circle.

enter image description here

(code for the animation at the bottom of the answer.)

Mathematica's Nearest function makes this relatively quick:

ADD: We can also connect each point on the inner/outer circles to it's closest point, to make the idea clearer:

Graphics[
 {
  Point[pts],
  Blue, {Thick, Line[pts[[ptIndices[rMin]]]]}, {Dashed, Opacity[0.6], 
   Circle[{0, 0}, rMin]},
  {Opacity[0.5], 
   Line /@ Transpose[{ptsOnCircle*rMin, 
      pts[[(nf /@ (ptsOnCircle*rMin))[[All, 1]]]]}]},
  Red, {Thick, Line[pts[[ptIndices[rMax]]]]}, {Dashed, Opacity[0.6], 
   Circle[{0, 0}, rMax]},
  {Opacity[0.5], 
   Line /@ Transpose[{ptsOnCircle*rMax, 
      pts[[(nf /@ (ptsOnCircle*rMax))[[All, 1]]]]}]},
  }, ImageSize -> 600]

enter image description here

To control the "jerkiness" of the lines, you can use a transform the "squashes" the points to a thinner ring:

enter image description here


Here's the code for the animation at the beginning:

Monitor[frames = Table[Graphics[
     {
      {AbsolutePointSize[1/300], Gray, Point[pts]},
      MapThread[
       Function[{r, col},
        Module[{nearest, poly},
         nearest = nf[ptsOnCircle[[i]]*r][[1]];
         poly = 
          Append[TakeWhile[ptIndices[r], # != nearest &], nearest];
         {              
          col, {Line[pts[[poly]]]}, {Dashed, Opacity[0.6], 
           Circle[{0, 0}, r]},
          {Thick, Line[{ptsOnCircle[[i]]*r, pts[[nearest]]}]}
          }]], {{rMin, rMax}, {Red, Blue}}]
      }, ImageSize -> 300], {i, 1, Length[ptsOnCircle], 5}];, i]

ListAnimate[frames]

I'm not sure which points you really want, so this is a stab in the dark: You could "walk around" the inner resp. outer circle, and pick the closest point in pts to every point on each circle. Mathematica's Nearest function makes this relatively quick:

ADD: We can also connect each point on the inner/outer circles to it's closest point, to make the idea clearer:

Graphics[
 {
  Point[pts],
  Blue, {Thick, Line[pts[[ptIndices[rMin]]]]}, {Dashed, Opacity[0.6], 
   Circle[{0, 0}, rMin]},
  {Opacity[0.5], 
   Line /@ Transpose[{ptsOnCircle*rMin, 
      pts[[(nf /@ (ptsOnCircle*rMin))[[All, 1]]]]}]},
  Red, {Thick, Line[pts[[ptIndices[rMax]]]]}, {Dashed, Opacity[0.6], 
   Circle[{0, 0}, rMax]},
  {Opacity[0.5], 
   Line /@ Transpose[{ptsOnCircle*rMax, 
      pts[[(nf /@ (ptsOnCircle*rMax))[[All, 1]]]]}]},
  }, ImageSize -> 600]

enter image description here

To control the "jerkiness" of the lines, you can use a transform the "squashes" the points to a thinner ring:

enter image description here

I'm not sure which points you really want, so this is a stab in the dark: You could "walk around" the inner resp. outer circle, and pick the closest point in pts to every point on each circle.

enter image description here

(code for the animation at the bottom of the answer.)

Mathematica's Nearest function makes this relatively quick:

To control the "jerkiness" of the lines, you can use a transform the "squashes" the points to a thinner ring:

enter image description here


Here's the code for the animation at the beginning:

Monitor[frames = Table[Graphics[
     {
      {AbsolutePointSize[1/300], Gray, Point[pts]},
      MapThread[
       Function[{r, col},
        Module[{nearest, poly},
         nearest = nf[ptsOnCircle[[i]]*r][[1]];
         poly = 
          Append[TakeWhile[ptIndices[r], # != nearest &], nearest];
         {              
          col, {Line[pts[[poly]]]}, {Dashed, Opacity[0.6], 
           Circle[{0, 0}, r]},
          {Thick, Line[{ptsOnCircle[[i]]*r, pts[[nearest]]}]}
          }]], {{rMin, rMax}, {Red, Blue}}]
      }, ImageSize -> 300], {i, 1, Length[ptsOnCircle], 5}];, i]

ListAnimate[frames]
added 5 characters in body
Source Link
Niki Estner
  • 36.4k
  • 3
  • 92
  • 156

ADD: We can also connect ofeach point on the inner/outer circles to it's closest point, to make the idea clearer:

ADD: We can also connect of point on the inner/outer circles it's closest point, to make the idea clearer:

ADD: We can also connect each point on the inner/outer circles to it's closest point, to make the idea clearer:

added 741 characters in body
Source Link
Niki Estner
  • 36.4k
  • 3
  • 92
  • 156

ADD: We can also connect of point on the inner/outer circles it's closest point, to make the idea clearer:

Graphics[
 {
  Point[pts],
  Blue, {Thick, Line[pts[[ptIndices[rMin]]]]}, {Dashed, Opacity[0.6], 
   Circle[{0, 0}, rMin]},
  {Opacity[0.5], 
   Line /@ Transpose[{ptsOnCircle*rMin, 
      pts[[(nf /@ (ptsOnCircle*rMin))[[All, 1]]]]}]},
  Red, {Thick, Line[pts[[ptIndices[rMax]]]]}, {Dashed, Opacity[0.6], 
   Circle[{0, 0}, rMax]},
  {Opacity[0.5], 
   Line /@ Transpose[{ptsOnCircle*rMax, 
      pts[[(nf /@ (ptsOnCircle*rMax))[[All, 1]]]]}]},
  }, ImageSize -> 600]

enter image description here

To control the "jerkiness" of the lines, you can use a transform the "squashes" the points to a thinner ring:

To control the "jerkiness" of the lines, you can use a transform the "squashes" the points to a thinner ring:

ADD: We can also connect of point on the inner/outer circles it's closest point, to make the idea clearer:

Graphics[
 {
  Point[pts],
  Blue, {Thick, Line[pts[[ptIndices[rMin]]]]}, {Dashed, Opacity[0.6], 
   Circle[{0, 0}, rMin]},
  {Opacity[0.5], 
   Line /@ Transpose[{ptsOnCircle*rMin, 
      pts[[(nf /@ (ptsOnCircle*rMin))[[All, 1]]]]}]},
  Red, {Thick, Line[pts[[ptIndices[rMax]]]]}, {Dashed, Opacity[0.6], 
   Circle[{0, 0}, rMax]},
  {Opacity[0.5], 
   Line /@ Transpose[{ptsOnCircle*rMax, 
      pts[[(nf /@ (ptsOnCircle*rMax))[[All, 1]]]]}]},
  }, ImageSize -> 600]

enter image description here

To control the "jerkiness" of the lines, you can use a transform the "squashes" the points to a thinner ring:

Source Link
Niki Estner
  • 36.4k
  • 3
  • 92
  • 156
Loading