TikZ で円の反転を描くにはどうすればいいですか?

TikZ で円の反転を描くにはどうすればいいですか?

点 P と中心 O を反転すると、直線 OP に沿った別の点 P' ができ、積 OP となります。OP' = k、つまり定数 k です。円を点 O (円内ではない) で反転すると、次の図のように別の円になります。 円の反転

TikZ で 2 番目の円を最初の円の (正しい) 反転として描くことは可能ですか? 平行移動、回転、その他の線形変換は簡単に実行できることは知っていますが、反転は見たことがありません。

答え1

TikZソリューションを待っている間に、図を作成する簡単な方法をご紹介します。メタポスト基本的な幾何学がよく説明されているMathworldで(ただし、図では点の反転を示している)反転円。この場合、は反転円の内側にあるため、Pとの役割P'が逆になります。P

ここでは、反転の円の一部の輪郭を淡いピンクで追加して、それがどのように機能するかを少しわかりやすくしています。もちろん、必要ない場合はピンクの弧を削除できます。

反転した円

prologues := 3;
outputtemplate := "%j%c.eps";

vardef invert_point(expr p, k) = 
  if abs(p)>0:
    unitvector p scaled (k/abs(p)) scaled k
  else:
    origin % strictly this should be a point at infinity
  fi
enddef;

vardef invert_path(expr P, k) = 
  for t=0 step 1/16 until length P-1/16:
     invert_point(point t of P, k) --
  endfor
  if cycle P:
     cycle
  else:
     invert_point(point infinity of P, k)
  fi
enddef;

beginfig(1);

path C, C'; 
pair P, P', Q; 

k = 150;
draw subpath (-1.4,1.4) of fullcircle scaled 2k withcolor .8[red,white];

C = fullcircle scaled 72 shifted 100 right;
P = point 1 of C;
C' = invert_path(C, k);
P' = invert_point(P, k);
Q = (origin -- P) intersectionpoint subpath (2,4) of C;

draw origin -- P';
draw origin -- center C' withcolor .5 white;
draw P'     -- center C' withcolor .5 white;
draw Q      -- center C  withcolor .5 white;

draw C; 
draw C' withcolor .78 blue; 

fill fullcircle scaled 3;
fill fullcircle scaled 3 shifted P;
fill fullcircle scaled 3 shifted Q;
fill fullcircle scaled 3 shifted P';
fill fullcircle scaled 3 shifted center C;
fill fullcircle scaled 3 shifted center C';

label(btex $O$  etex, origin + (-6,3));
label(btex $P$  etex, P      + (+3,7));
label(btex $P'$ etex, P'     + (-3,7));
label(btex $Q$  etex, Q      + (-3,7));
label(btex $C$  etex, point 5.5 of C + (-3,-7));

endfig;
end

ノート

  • 簡単にするために、invert_point反転円は原点を中心としていると仮定します。しかし、半径の代わりに任意の円を受け入れるようにサブルーチンを調整することは難しくありませんk

  • ここでも、簡単にするために、 とpathの2 つの異なる関数を用意しましたpointが、単一のinvert関数を簡単に作成し、 と を使用してif path Pif pair P渡された内容に応じて適切なアクションを選択することもできます。

  • この式は unitvector p scaled (k/abs(p)) scaled k、より自然に と記述できますが、 を181 より大きい値にunitvector p scaled (k**2/abs(p))設定すると、算術オーバーフロー エラーが発生します。これは、 が、プレーン MP で許可される最大値より大きいためです。これを回避するには、私が示したようにコード化するか、 を使用して処理します。k182**22**15mpost -numbersytem=double

  • 有限の図では無限大を簡単に表現できないため、原点の点を反転するためにこれを使用しないでください。

答え2

私はTikzで次のように解決しました。

まず、2 つの異なる反転があります。

  1. その点は反転円の内側にあります。
  2. ポイントはその外側にあります。

まず、2 番目のケースから始めます。点「O」(「k」と呼びます) を中心とした円を描き、円「k」の外側にある点「P」の反転点を探します。

まず知っておく必要があるのは、「P」から「k」への接点の 1 つです。この点の線「OP」への投影は、「P」の反転点です。

\documentclass{article}
\usepackage{tikz}
    \usetikzlibrary{calc}
    \usetikzlibrary{intersections}
    \begin{document}
    \begin{tikzpicture}
        \coordinate (O) at (0,0);
        \coordinate (P) at (5,0);
        \draw[red,thick,name path=circ1](O)circle(2);
        %
        % I look for the midpoint of O and P. This point will be the centre of
        % an arc whose intersection with k will give me the tangent points
        %
        \path(O)--coordinate[midway](M)(P);
        %
        % I draw the arc whose intersection with circle are the 2 tangent points
        %
        \path[name path=circ2] let
            \p1=(O),
            \p2=(M),
            \n1={veclen(\x2-\x1,\y2-\y1)} in
            ($(M)+({\n1*cos(130)},{\n1*sin(130)})$) arc (130:230:\n1);
        \path[name intersections={of=circ1 and circ2}]
            (intersection-1) coordinate (Tg1)
            (intersection-2) coordinate (Tg2);
        \draw[blue]
            (A)--(Tg1)
            (O)--node[midway,left,black]{$\mathtt{r}$}(B)
            (O)--(A);
        %
        % Here we are. This projection is the inversion of point P with regards
        % to circle k
        %
        \draw[orange](Tg1)--($(O)!(Tg1)!(P)$)coordinate(InvP);
        %
        \draw[black,line width=.75,fill=white]
            (P)circle(1.5pt)node[black,below]{$\mathtt{P}$};
        \draw[black,line width=.75,fill=white]
            (O)circle(1.5pt)node[black,below]{$\mathtt{O}$};
        \draw[black,line width=.75,fill=white]
            (Tg1)circle(1.5pt)node[black,below]{$\mathtt{Tg1}$};
        \draw[black,line width=.75,fill=white]
            (InvP)circle(1.5pt)node[black,below]{$\mathtt{P'}$};
        \node at (-1.75,0) {$\symtt{k}$};
    \end{tikzpicture}
\end{document}

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

点が円の内側にある場合、OP からの垂線を見つけ、この線と円 k (TgP と呼ぶ) の交点を見つけ、この点から接線を引き、OP との交点を見つけるだけです。

関連情報