特定絕對點而不是相對點的法線和切線向量

特定絕對點而不是相對點的法線和切線向量

我想在曲線上的特定點繪製法向量。我查了幾個問題(例如1,2,3等等)並且答案包含了在給定點處繪製曲線的切線或法線向量的很好的解決方案,該給定點由 0 到 1 之間的變量指定,給出了在曲線上移動的距離。

另一個例子使用絕對距離,但該座標仍然沿著曲線「移動」。

然而,我有幾條曲線,我知道一個點的絕對座標(相對於圖片的座標系),但不確切地知道它在該相對座標中位於該曲線上的位置。

在下面的(不是最小的,但是有效的)範例中,我使用了非常有用的程式碼這個答案透過反覆試驗發現我的點P的相對座標大約是0.5573。由於我將其用於不同類型的曲線和不同的點,因此嘗試非常乏味。有絕對座標的好解決方案嗎?

\documentclass[]{scrartcl}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{arrows,calc,positioning,decorations,decorations.markings,quotes,angles}
\tikzset{tangent/.style={
        decoration={
            markings,% switch on markings
            mark=
            at position #1
            with
            {
                \coordinate (tangent point-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
                \coordinate (tangent unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
                \coordinate (tangent orthogonal unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,1);
            }
        },
        postaction=decorate
    },
    use tangent/.style={
        shift=(tangent point-#1),
        x=(tangent unit vector-#1),
        y=(tangent orthogonal unit vector-#1)
    },
    use tangent/.default=1}
\begin{document}
\begin{tikzpicture}[%baseline={([yshift=-.0ex]current bounding box.center)},
    kvect/.style={->,>=stealth}]
    % coordinates
    \coordinate(O) at (0,0);
    \coordinate(OAend) at (90:5.5);
    \coordinate(OAstart) at (-90:.5);
    \coordinate(X1) at (180:.5);
    \coordinate(X2) at (0:3.5);
    \coordinate(P) at (40:3cm and 5cm);
    \coordinate(P2) at ($1.5*(P)$);
    \coordinate(ARCSTART) at (-10:3cm and 5cm);
    % curve
    \draw[tangent=0.5573,color=darkgray] (ARCSTART) arc  (-10:95:3cm and 5cm);
    % other lines
    \path[kvect] (OAstart) edge (OAend); % optical axis
    \path[kvect] (X1) edge (X2);
    \path[kvect,color=green] (O) edge (P);
    \path[dashed,color=green] (P) edge (P2);
    \path [kvect,color=green, use tangent](0,0) edge (0,-3) [] {};
    \path [use tangent](0,0) -- (0,-3) node (Sp) [] {};
    \path pic["$\rho$",angle eccentricity=1.5,angle radius=0.6cm,draw,<-,>=stealth,color=green] {angle = Sp--P--P2};
    \path pic["$\theta$",angle eccentricity=1.5,angle radius=0.6cm,draw] {angle = P--O--OAend};
\end{tikzpicture}
\end{document}

範例的螢幕截圖

答案1

使用茲圖包裹:

在此輸入影像描述

\documentclass[tikz]{standalone}
    
\usepackage{tzplot}

\begin{document}

\begin{tikzpicture}[font=\scriptsize]
\tzhelplines(7,6)
\tzaxes(7,6)
\tzcoor(40:3 and 5)(P)
\tzcoor($1.5*(P)$)(P2)
\tzarcfrom[gray]"arcA"(-10:3 and 5)(-10:95:3 and 5)
\tzline[->,green](0,0)(P)
\tzline[dashed,green](P)(P2)
\tztangent[blue!20,thin]"tan"{arcA}(P)[1:3.5]{tangent}[r]
\tzhXpointat{tan}{2}(P3a)        % (P3a): point on tangent line
\tzcoor($(P)!1cm!90:(P3a)$)(P3)  % (P3) : point on normal  line
\tzgetxyval(P){\Px}{\Py}
\tzslopeat[->,green,tzextend={0pt}{2cm}]{arcA}{\Px}{.1pt}[90]
\tzanglemark[->,green](P2)(P)(P3){$\rho$}[green]
\tzrightanglemark(P3)(P)(P3a)
\tzanglemark(P)(0,0)(1,0){$\theta$}
\end{tikzpicture}

\end{document}

相關內容