2011-09-17 11 views
7

podstawie Sjoerd, świetne rozwiązanie i przedłużenie na From Cartesian Plot to Polar Histogram using Mathematica, należy rozważyć następujące:arctan Binning, z działki na histogramie sztuczki

list = {{21, 16}, {16, 14}, {11, 11}, {11, 12}, 
     {13, 15}, {18, 17}, {19, 11}, {17, 16}, {16, 19}} 

ScreenCenter = {20, 15} 

ListPolarPlot[{ArcTan[##], EuclideanDistance[##]} & @@@ (# - ScreenCenter & /@ list), 
       PolarAxes -> True, PolarGridLines -> Automatic, Joined -> False, 
       PolarTicks -> {"Degrees", Automatic}, 
       BaseStyle -> {FontFamily -> "Arial", FontWeight -> Bold, 
       FontSize -> 12}, PlotStyle -> {Red, PointSize -> 0.02}] 

enter image description here

Module[{Countz, maxScale, angleDivisions, dAng}, 
     Countz = Reverse[BinCounts[[email protected][ArcTan[#[[1]] - ScreenCenter[[1]], #[[2]] - 
       ScreenCenter[[2]]] &, list, {1}], {-\[Pi], \[Pi], \[Pi]/6}]]; 
     maxScale = 4; 
     angleDivisions = 12; 
     dAng = (2 \[Pi])/angleDivisions; 

SectorChart[{ConstantArray[1, Length[Countz]], Countz}\[Transpose], 
      SectorOrigin -> {-\[Pi]/angleDivisions, "Counterclockwise"}, 
      PolarAxes -> True, 
      PolarGridLines -> Automatic, 
      PolarTicks -> {Table[{i \[Degree] + \[Pi]/angleDivisions,i \[Degree]}, 
      {i, 0, 345, 30}], Automatic}, 
      ChartStyle -> {Directive[EdgeForm[{Black, Thickness[0.005]}], Red]}, 
      BaseStyle -> {FontFamily -> "Arial", FontWeight -> Bold, 
      FontSize -> 12}, ImageSize -> 400]] 

enter image description here

Jak widać, histogram pokazuje obrotową symetrię tego, co powinno. Próbowałem wszystkiego, aby uzyskać proste, ale nie udało. Bez Reverse jest najgorsze. Próbowałem RotateRight bez sukcesu. Czuję, że problem jest w moim BinCount. Wyjście ArcTan z -Pi do Pi, podczas gdy Sjoerd zasugerował, że muszę przejść od 0 do 2Pi. Ale nie rozumiem, jak to zrobić.

EDYCJA: Problem rozwiązany. Dzięki Sjoerdowi, Belizariuszowi, rozwiązaniom Heike'a, jestem w stanie pokazać histogram lokalizacji fiksacji oka, biorąc pod uwagę środek ciężkości obrazu.

enter image description here

+0

@beliarius: Przy użyciu 'ArcTan' w postaci' arctan [x, y] 'zasięg to' (-Pi, Pi) ' – Heike

+0

@belisarius, Przepraszam, jestem po prostu z tego powodu :-(Dziękuję za pomoc! – 500

+0

@ 500 Zwróć uwagę na rozwiązanie Heike jako wydaje się pasować do pozycji lepiej –

Odpowiedz

5

Można użyć opcji ChartElementFunction do pozycji sektory dokładnie. Pierwszy argument ChartElementFunction ma postać {{angleMin, angleMax}, {rMin,rMax}}. Pierwszy sektor ma granic {angleMin, angleMax} = {-Pi/12, Pi/12}, drugi {Pi/12, 3 Pi/12} itd Dlatego, aby uzyskać odpowiedni obrót mógłby zrobić coś jak

Module[{Countz, maxScale, angleDivisions, dAng}, 
maxScale = 4; 
angleDivisions = 12; 
dAng = (2 \[Pi])/angleDivisions; 
Countz = BinCounts[ 
    [email protected][ArcTan @@ (# - ScreenCenter) &, list, {1}], 
    {-Pi, Pi, dAng}]; 

SectorChart[{ConstantArray[1, Length[Countz]], Countz}\[Transpose], 
    SectorOrigin -> {-\[Pi]/angleDivisions, "Counterclockwise"}, 
    PolarAxes -> True, PolarGridLines -> Automatic, 
    PolarTicks -> {Table[{i \[Degree] + \[Pi]/angleDivisions, 
     i \[Degree]}, {i, 0, 345, 30}], Automatic}, 
    ChartStyle -> {Directive[EdgeForm[{Black, Thickness[0.005]}], Red]}, 
    BaseStyle -> {FontFamily -> "Arial", FontWeight -> Bold, FontSize -> 12}, 
    ImageSize -> 400, 

    ChartElementFunction -> 
    Function[{range}, Disk[{0, 0}, range[[2, 2]], - 11 Pi/12 + range[[1]]]]]] 

enter image description here

+0

w momencie, gdy myślałem, że jestem dobry, wracam i widzę twoje rozwiązanie, a belisarius komentuje, dziękuję, że nawet nie zwróciłem uwagi na lokalizację lokalu, w którym jest tak schludnie. – 500

6

Tylko sprawdzam teraz, ale Twoja pierwsza fabuła wydaje się błędna:

list = {{21, 16}, {16, 14}, {11, 11}, {11, 12}, {13, 15}, 
     {18, 17}, {19, 11}, {17, 16}, {16, 19}}; 
ScreenCenter = {20, 15}; 

Show[ListPlot[list, PlotStyle -> Directive[PointSize[Medium], Purple]], 
    Graphics[ 
       {Red, PointSize[Large], Point[ScreenCenter], 
       Circle[ScreenCenter, 10]}], 
AspectRatio -> 1, Axes -> False] 

enter image description here

ListPolarPlot[{ArcTan[Sequence @@ ##], Norm[##]} &/@ (#-ScreenCenter & /@ list), 
PolarAxes -> True, 
PolarGridLines -> Automatic, 
Joined -> False, 
PolarTicks -> {"Degrees", Automatic}, 
BaseStyle -> {FontFamily -> "Arial", FontWeight -> Bold, FontSize -> 12}, 
PlotStyle -> {Red, PointSize -> 0.02}] 

enter image description here

Edit

nie następuje cały swój kod, ale odbicie na środku ekranu wydaje się naprawić rzeczy:

Module[{Countz, maxScale, angleDivisions, dAng}, 
Countz = BinCounts[ 
       {ArcTan[Sequence @@ ##]} & /@ (# + ScreenCenter & /@ -list), 
      {-Pi, Pi, Pi/6}]; 
maxScale = 4; 
angleDivisions = 12; 
dAng = (2 Pi)/angleDivisions; 

SectorChart[{ConstantArray[1, Length[Countz]], Countz}\[Transpose], 

    SectorOrigin -> {-Pi/angleDivisions, "Counterclockwise"}, 
    PolarAxes -> True, 
    PolarGridLines -> Automatic, 
    PolarTicks -> {Table[{i \[Degree] + Pi/angleDivisions, 
         i \[Degree]}, {i, 0, 345, 30}], Automatic}, 
    ChartStyle -> {Directive[EdgeForm[{Black, Thickness[0.005]}], Red]}, 
    BaseStyle -> {FontFamily -> "Arial", FontWeight -> Bold, 
    FontSize -> 12}, 
    ImageSize -> 400]] 

enter image description here

Edycja

Tutaj można zobaczyć mała niewspółosiowość w moim kodzie, rozwiązana w odpowiedzi Heike'a (głosuj na to!)

Show[Module[{Countz, maxScale, angleDivisions, dAng}, 
    Countz = BinCounts[{ArcTan[ 
     Sequence @@ ##]} & /@ (# + 
     ScreenCenter & /@ -list), {-\[Pi], \[Pi], \[Pi]/6}]; 
    maxScale = 4; 
    angleDivisions = 12; 
    dAng = (2 \[Pi])/angleDivisions; 
    SectorChart[{ConstantArray[1, Length[Countz]], Countz}\[Transpose], 
    SectorOrigin -> {-\[Pi]/angleDivisions, "Counterclockwise"}, 
    PolarAxes -> True, PolarGridLines -> Automatic, 
    PolarTicks -> {Table[{i \[Degree] + \[Pi]/angleDivisions, 
     i \[Degree]}, {i, 0, 345, 30}], Automatic}, 
    ChartStyle -> {Directive[EdgeForm[{Black, Thickness[0.005]}], 
     Red]}, BaseStyle -> {FontFamily -> "Arial", FontWeight -> Bold, 
    FontSize -> 12}, ImageSize -> 400]], 
ListPlot[Plus[# - ScreenCenter] & /@ list/2.5, 
    PlotMarkers -> Image[CrossMatrix[10], ImageSize -> 10]] 
] 

enter image description here