Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a set of points P that are evenly spaced on a square grid of length 1...

I would like to map these points to the circle of radius 1 as nicely as possible, while preserving relative positions as much as possible. That is, the points in the square grid should map to the points in the unit circle.

How can this be done in Mathematica?

share|improve this question
    
Assuming that a map is a function, by what criterion should the mapping be done? Closest (highlighted) point on the unit circle? –  David Carraher Aug 30 at 8:13
    
Do the circle and square have the same center? (e.g. {0,0})? –  David Carraher Aug 30 at 8:20
1  
Do you mean Circle or Disk? –  shrx Aug 30 at 8:48

1 Answer 1

Your question is a little vague but one possible mapping from a square to a circle is the following.

enter image description here

This transformation wrapped into a Mathematica function:

transformation[points_] := {#[[1]] Sqrt[1 - (#[[2]]^2/2)],
       #[[2]] Sqrt[1 - (#[[1]]^2/2)]} & /@ # & /@ points;

And a little demonstration:

points = Table[{a, b}, {a, -1, 1, 0.2}, {b, -1, 1, 0.2}];

Show[
 Graphics[{EdgeForm[Thick], White, Rectangle[{-1, -1}, {1, 1}]}],
 ListPlot[Flatten[points, 1], AspectRatio -> 1, PlotStyle -> Red]
 ]
Show[
 Graphics[{Thick, Circle[]}],
 ListPlot[Flatten[transformation[points], 1], AspectRatio -> 1, PlotStyle -> Red]
 ]

enter image description here

share|improve this answer
    
Nice answer, but no need for Show and ListPlot. Suggest Graphics[{EdgeForm[Thick], FaceForm[None], Rectangle[{-1, -1}, {1, 1}], Red, PointSize[Medium], Point[Flatten[points, 1]]}] and Graphics[{Thick, Circle[], Red, PointSize[Medium], Point[Flatten[transformation@points, 1]]}] –  m_goldberg Aug 30 at 5:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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