평면 위의 점 투영을 찾는 더 간단한 답이 있습니까?

평면 위의 점 투영을 찾는 더 간단한 답이 있습니까?

여기에서평면상의 점 투영 좌표를 찾는 명령이 있습니까?, 답변을 받았습니다. 나는 calc 라이브러리가 업데이트되었고 calc가 CTAN에 업데이트되기 훨씬 전에 업데이트되었다는 것을 알고 있습니다. 나는 이 방정식에 대한 더 간단한 답이 있기를 바랍니다.

답변1

업데이트: 다음을 사용하여 몇 가지 추가 개발실험적인3dtools 라이브러리. 아직 이 이야기의 마지막 말이 아니길 바랍니다.

\documentclass[border=3mm,12pt,tikz]{standalone}
\usepackage{tikz-3dplot} 
\usetikzlibrary{3dtools}
\tikzset{3d projection of point/.style args={(#1,#2,#3) on plane through (#4,#5,#6)
with normal (#7,#8,#9)}{
/utils/exec={\pgfmathsetmacro{\myprefactor}{(#7*(#1-#4)%
+#8*(#2-#5)+#9*(#3-#6))%
/(#7*#7+#8*#8+#9*#9)}
\pgfmathsetmacro{\myx}{#1-\myprefactor*#7}
\pgfmathsetmacro{\myy}{#2-\myprefactor*#8}
\pgfmathsetmacro{\myz}{#3-\myprefactor*#9}},
insert path={%
({\myx},{\myy},{\myz})}},% symbolic version
symbolic 3d projection of point/.style args={#1 on plane through #2
with normal #3}{insert path={let \p1=(#1),\p2=(#2),\p3=(#3) in 
[3d projection of point/.expanded=\coord1 on plane through \coord2 with normal \coord3]}}}

\begin{document}
    \tdplotsetmaincoords{70}{110}
    \begin{tikzpicture}[tdplot_main_coords,scale=1.5]
    \pgfmathsetmacro\a{4}
    \pgfmathsetmacro\b{3}
    \pgfmathsetmacro\c{4}
    % define the coordinates (note: \coordinate (A) at (0,0,0) does *NOT* work)
    \path (0,0,0) coordinate(A)
        (\a,0,0) coordinate (B)
        (0,\b,0) coordinate (C)                           
        (0,0,\c) coordinate (S)
        [overlay,3d coordinate={(n)=(C)-(B)x(S)-(B)}];
    % do the projection
    \path[symbolic 3d projection of point={A on plane through S with
          normal n}]  coordinate (H);
    % draw various parts          
    \draw[dashed,thick] (A) -- (B)  (A) -- (C)  (S)--(A) --(H) ;
    \draw[thick]    (S) -- (B) -- (C) -- cycle;
    \foreach \point/\position in {A/left,B/left,C/below,S/above,H/above}
    {
        \fill (\point) circle (1.5pt);
        \node[\position=3pt] at (\point) {$\point$};
    }
    \end{tikzpicture}
\end{document} 

이것은 업그레이드이지만 진화하는 이야기의 마지막 단어는 아닐 것입니다. 여기 파서를 사용하면 기호 좌표로 작업할 수 있습니다. 코드는 여러 정의를 포함하고 있기 때문에 길며, 언젠가는 라이브러리에 포함될 수 있기를 바랍니다. 이러한 트릭은 다음을 통해 가능해졌습니다.Henri Menke의 최근 커밋, 그리고 사용되었습니다여기. 불행하게도 이 버전에서는 기호 좌표와 명시적 좌표를 혼합할 수 없습니다. 이제 다음과 같은 기호 좌표를 사용할 수 있습니다.

\path[symbolic 3d projection of point={A on plane through S with
          normal n}]  coordinate (H);

법선은 n기호 좌표로부터 계산될 수 있습니다. 그것은 다음과 같이 주어진다:

 n = (C-B) x (S-B)

그리고 계산은 다음과 같이 수행됩니다.

\lincomb(CB)=1*(C)+(-1)*(B);
\lincomb(SB)=1*(S)+(-1)*(B);
\vecprod(n)=(CB)x(SB);

즉, 먼저 선형 조합을 형성해야 하며 C-B그런 S-B다음 이들의 벡터 곱을 계산할 수 있습니다. 중첩된 구문 분석을 위해서는 구문 분석 전문가가 이를 살펴봐야 합니다.

\documentclass[border=3mm,12pt,tikz]{standalone}
\usepackage{tikz-3dplot} 
% allows us to do linear combinations
\def\lincomb#1=#2*#3+#4*#5;{%
\path[overlay] let \p1=#3,\p2=#5 in 
({(#2)*(xcomp3\coord1)+(#4)*(xcomp3\coord2)},%
 {(#2)*(ycomp3\coord1)+(#4)*(ycomp3\coord2)},%
 {(#2)*(zcomp3\coord1)+(#4)*(zcomp3\coord2)}) coordinate #1;}
\def\vecprod#1=#2x#3;{%
\path[overlay] let \p1=#2,\p2=#3 in 
 ({vpx({\coord1},{\coord2})},%
 {vpy({\coord1},{\coord2})},%
 {vpz({\coord1},{\coord2})}) coordinate #1;}
\pgfmathdeclarefunction{xcomp3}{3}{% x component of a 3-vector
\begingroup%
  \pgfmathparse{#1}%
  \pgfmathsmuggle\pgfmathresult\endgroup}
\pgfmathdeclarefunction{ycomp3}{3}{% y component of a 3-vector
\begingroup%
  \pgfmathparse{#2}%
  \pgfmathsmuggle\pgfmathresult\endgroup}  
\pgfmathdeclarefunction{zcomp3}{3}{% z component of a 3-vector
\begingroup%
  \pgfmathparse{#3}%
  \pgfmathsmuggle\pgfmathresult\endgroup}
% vector product auxiliary functions
\newcommand{\vpauxx}[6]{(#2)*(#6)-(#3)*(#5)}     
\newcommand{\vpauxy}[6]{(#4)*(#3)-(#1)*(#6)}
\newcommand{\vpauxz}[6]{(#1)*(#5)-(#2)*(#4)}
% vector product pgf functions
\pgfmathdeclarefunction{vpx}{2}{% x component of vector product
  \begingroup%
  \pgfmathparse{\vpauxx#1#2}%
  \pgfmathsmuggle\pgfmathresult\endgroup}
\pgfmathdeclarefunction{vpy}{2}{% y component of vector product
  \begingroup%
  \pgfmathparse{\vpauxy#1#2}%
  \pgfmathsmuggle\pgfmathresult\endgroup}
\pgfmathdeclarefunction{vpz}{2}{% z component of vector product
  \begingroup%
  \pgfmathparse{\vpauxz#1#2}%
  \pgfmathsmuggle\pgfmathresult\endgroup}
% original version of projection (works with symbolic coordinates)  
\tikzset{3d projection of point/.style args={(#1,#2,#3) on plane through (#4,#5,#6)
with normal (#7,#8,#9)}{
/utils/exec={\pgfmathsetmacro{\myprefactor}{(#7*(#1-#4)%
+#8*(#2-#5)+#9*(#3-#6))%
/(#7*#7+#8*#8+#9*#9)}
\pgfmathsetmacro{\myx}{#1-\myprefactor*#7}
\pgfmathsetmacro{\myy}{#2-\myprefactor*#8}
\pgfmathsetmacro{\myz}{#3-\myprefactor*#9}},
insert path={%
({\myx},{\myy},{\myz})}},% symbolic version
symbolic 3d projection of point/.style args={#1 on plane through #2
with normal #3}{insert path={let \p1=(#1),\p2=(#2),\p3=(#3) in 
[3d projection of point/.expanded=\coord1 on plane through \coord2 with normal \coord3]}}}

\begin{document}
    \tdplotsetmaincoords{70}{110}
    \begin{tikzpicture}[tdplot_main_coords,scale=1.5]
    \pgfmathsetmacro\a{4}
    \pgfmathsetmacro\b{3}
    \pgfmathsetmacro\c{4}
    % define the coordinates (note: \coordinate (A) at (0,0,0) does *NOT* work)
    \path (0,0,0) coordinate(A)
        (\a,0,0) coordinate (B)
        (0,\b,0) coordinate (C)                           
        (0,0,\c) coordinate (S);
    \lincomb(C-B)=1*(C)+(-1)*(B);
    \lincomb(S-B)=1*(S)+(-1)*(B);
    % compute the normal n
    \vecprod(n)=(C-B)x(S-B);
    % do the projection
    \path[symbolic 3d projection of point={A on plane through S with
          normal n}]  coordinate (H);
    % draw various parts          
    \draw[dashed,thick] (A) -- (B)  (A) -- (C)  (S)--(A) --(H) ;
    \draw[thick]    (S) -- (B) -- (C) -- cycle;
    \foreach \point/\position in {A/left,B/left,C/below,S/above,H/above}
    {
        \fill (\point) circle (1.5pt);
        \node[\position=3pt] at (\point) {$\point$};
    }
    \end{tikzpicture}
\end{document} 

여기에 이미지 설명을 입력하세요

이 파서는 투영을 직접 계산할 수도 있습니다. 우리 는 의 A투영 에서 빼야 합니다 . 이는 직접 수행할 수 있습니다(물론 동일한 출력이 생성됩니다).A-SnH = A - (((A-S).(n))/((n).(n))) * n

\documentclass[border=3mm,12pt,tikz]{standalone}
\usepackage{tikz-3dplot} 
% allows us to do linear combinations
\def\lincomb#1=#2*#3+#4*#5;{%
\path[overlay] let \p1=#3,\p2=#5 in 
({(#2)*(xcomp3\coord1)+(#4)*(xcomp3\coord2)},%
 {(#2)*(ycomp3\coord1)+(#4)*(ycomp3\coord2)},%
 {(#2)*(zcomp3\coord1)+(#4)*(zcomp3\coord2)}) coordinate #1;}
% vector product
\def\vecprod#1=#2x#3;{%
\path[overlay] let \p1=#2,\p2=#3 in 
 ({vpx({\coord1},{\coord2})},%
 {vpy({\coord1},{\coord2})},%
 {vpz({\coord1},{\coord2})}) coordinate #1;}
% scalar product 
\makeatletter
\def\scalprod#1=#2.#3;{%
\path[overlay] let \p1=#2,\p2=#3 in 
\pgfextra{\pgfmathsetmacro\pgfutil@tmpa{scalarproduct({\coord1},{\coord2})}
\xdef\pgfutil@tmpa{\pgfutil@tmpa}};%
\edef#1{\pgfutil@tmpa}}%
\makeatother 
\newcommand{\spaux}[6]{(#1)*(#4)+(#2)*(#5)+(#3)*(#6)}  
\pgfmathdeclarefunction{scalarproduct}{2}{% scalar product of two 3-vectors
  \begingroup%
  \pgfmathparse{\spaux#1#2}%
  \pgfmathsmuggle\pgfmathresult\endgroup}  
% projections
\pgfmathdeclarefunction{xcomp3}{3}{% x component of a 3-vector
\begingroup%
  \pgfmathparse{#1}%
  \pgfmathsmuggle\pgfmathresult\endgroup}
\pgfmathdeclarefunction{ycomp3}{3}{% y component of a 3-vector
\begingroup%
  \pgfmathparse{#2}%
  \pgfmathsmuggle\pgfmathresult\endgroup}  
\pgfmathdeclarefunction{zcomp3}{3}{% z component of a 3-vector
\begingroup%
  \pgfmathparse{#3}%
  \pgfmathsmuggle\pgfmathresult\endgroup}
% vector product auxiliary functions
\newcommand{\vpauxx}[6]{(#2)*(#6)-(#3)*(#5)}     
\newcommand{\vpauxy}[6]{(#4)*(#3)-(#1)*(#6)}
\newcommand{\vpauxz}[6]{(#1)*(#5)-(#2)*(#4)}
% vector product pgf functions
\pgfmathdeclarefunction{vpx}{2}{% x component of vector product
  \begingroup%
  \pgfmathparse{\vpauxx#1#2}%
  \pgfmathsmuggle\pgfmathresult\endgroup}
\pgfmathdeclarefunction{vpy}{2}{% y component of vector product
  \begingroup%
  \pgfmathparse{\vpauxy#1#2}%
  \pgfmathsmuggle\pgfmathresult\endgroup}
\pgfmathdeclarefunction{vpz}{2}{% z component of vector product
  \begingroup%
  \pgfmathparse{\vpauxz#1#2}%
  \pgfmathsmuggle\pgfmathresult\endgroup}
\begin{document}
    \tdplotsetmaincoords{70}{110}
    \begin{tikzpicture}[tdplot_main_coords,scale=1.5]
    \pgfmathsetmacro\a{4}
    \pgfmathsetmacro\b{3}
    \pgfmathsetmacro\c{4}
    % define the coordinates (note: \coordinate (A) at (0,0,0) does *NOT* work)
    \path (0,0,0) coordinate(A)
        (\a,0,0) coordinate (B)
        (0,\b,0) coordinate (C)                           
        (0,0,\c) coordinate (S);
    \lincomb(C-B)=1*(C)+(-1)*(B);
    \lincomb(S-B)=1*(S)+(-1)*(B);
    \lincomb(A-S)=1*(A)+(-1)*(S);
    % compute the normal n
    \vecprod(n)=(C-B)x(S-B);
    % projection of (A-S) on n
    \scalprod\mysp=(A-S).(n);
    % square of n
    \scalprod\myln=(n).(n);
    % H = A - (((A-S).(n))/((n).(n))) * n
    \lincomb(H)=1*(A)+{(-1*(\mysp)/\myln)}*(n);
    % draw various parts          
    \draw[dashed,thick] (A) -- (B)  (A) -- (C)  (S)--(A) --(H) ;
    \draw[thick]    (S) -- (B) -- (C) -- cycle;
    \foreach \point/\position in {A/left,B/left,C/below,S/above,H/above}
    {
        \fill (\point) circle (1.5pt);
        \node[\position=3pt] at (\point) {$\point$};
    }
    \end{tikzpicture}
\end{document} 

답변2

이는 Asymptote planeproject모듈의 명령을 사용하여 쉽게 수행할 수 있습니다 .three

여기에 이미지 설명을 입력하세요

// http://asymptote.ualberta.ca/
unitsize(1cm);
import three;
currentprojection=orthographic(2,4,1,zoom=.8);
triple A=(3,0,0), B=(0,6,0), C=(0,0,4);

path3 base=A--B--C--cycle;
triple H=planeproject(base,normal(base))*O;

draw(O--A^^O--B^^O--C,dashed);
draw(O--H,red);
draw(base);

dot("$A$",A,W);
dot("$B$",B,E);
dot("$C$",C,N);
dot("$O$",O,NE);
dot("$H$",H,SW,red);

관련 정보