7

Sjoerdに基づいて、数学を使用したデカルトプロットから極ヒストグラムへの優れたソリューションと拡張機能について、次のことを考慮してください。

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}]

ここに画像の説明を入力してください

Module[{Countz, maxScale, angleDivisions, dAng},
        Countz = Reverse[BinCounts[Flatten@Map[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]]

ここに画像の説明を入力してください

ご覧のとおり、ヒストグラムは、あるべきものの回転対称性を示しています。私はそれらをまっすぐにするためにすべてを試みましたが、成功しませんでした。リバースなしでは最悪です。RotateRightを試しましたが成功しませんでした。問題はBinCountにあると感じています。ArcTanは-PiからPiに出力しますが、Sjoerdは0から2Piに移動する必要があることを示唆しました。しかし、その方法がわかりません。

編集:問題は解決しました。Sjoerd、Belisarius、Heikeのソリューションのおかげで、画像の重心が与えられた場合の固視位置のヒストグラムを表示することができます。

ここに画像の説明を入力してください

4

2 に答える 2

6

今チェックしているだけですが、最初のプロットに欠陥があるようです。

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]

ここに画像の説明を入力してください

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}]  

ここに画像の説明を入力してください

編集

私はあなたのすべてのコードに従ったわけではありませんが、スクリーンセンターでの反射は問題を修正しているようです:

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]]

ここに画像の説明を入力してください

編集

ここで、私のコードに小さなずれが見られるかもしれません。これは、平家の答えで解決されています(投票してください!)

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]]
 ]

ここに画像の説明を入力してください

于 2011-09-17T20:18:49.277 に答える
5

このオプションを使用してChartElementFunction、セクターを正確に配置できます。の最初の引数ChartElementFunctionはの形式{{angleMin, angleMax}, {rMin,rMax}}です。最初のセクターには境界{angleMin, angleMax} = {-Pi/12, Pi/12}があり、2番目のセクターには境界があります{Pi/12, 3 Pi/12}。したがって、正しい回転を得るには、次のようなことを行うことができます。

Module[{Countz, maxScale, angleDivisions, dAng},
 maxScale = 4;
 angleDivisions = 12;
 dAng = (2 \[Pi])/angleDivisions;
 Countz = BinCounts[
   Flatten@Map[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]]]]]]

ここに画像の説明を入力してください

于 2011-09-17T20:35:44.830 に答える