[Tex/LaTex] Calculating a point in TikZ that completes a right trangle

calculationstikz-pgftkz-euclide

I am trying to draw an incline plane free body diagram for my Physics class ( a little like the one pictured here):

enter image description here

Currently, my code looks like this (using TikZ, tkz-euclide, TiKz libraries calc and plotmarks):

\begin{tikzpicture}[scale=0.8, transform shape] %incline plane
%triangle coordinates
\coordinate (A) at (0,0);
\coordinate (B) at (7,0);
\coordinate (C) at (0,5);
%box coordinates
\coordinate (D) at ($(C)!3/8!(B)$);
\coordinate (E) at ($(C)!5/8!(B)$);
\coordinate [label=below:$F$](F) at ($(C)!1/2!(B)$);
\coordinate (G) at ($(E)!1!-90:(F)$);
\coordinate (H) at ($(D)!1!90:(F)$);
\coordinate (I) at ($(F)!1!90:(E)$);
\coordinate [label=above:$J$](J) at ($(F)!1/2!(I)$);
%vector coordinates
\coordinate [label=left:$K$] (K) at ($(A)!1/4!(C)$);

\draw (D) -- (E) -- (G) -- (H) -- cycle;
\draw (F) -- (J);
\draw (F) -- (K);

\path plot[mark=*] coordinates {(J)};

%draw and label triangle
\tkzDrawPolygon(A,B,C)
\tkzMarkAngle(C,B,A)
\tkzLabelAngle[left,pos=1](C,B,A){$\theta$}
\tkzMarkRightAngle(C,A,B)


\end{tikzpicture}

Which will render the following:
enter image description here

How can I calculate a point that finishes a right triangle with F and K, so I can draw a vector going down 3/4 of the way (the vector m*g) of the triangle, starting from J (the point in the center of the box)?

Best Answer

I might have not understood the requirement properly but is it like this?

\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
    \usetikzlibrary{calc}

\begin{document}
  \begin{tikzpicture}[scale=0.8, transform shape] %incline plane
%triangle coordinates
\coordinate (A) at (0,0);
\coordinate (B) at (7,0);
\coordinate (C) at (0,5);
%box coordinates
\coordinate (D) at ($(C)!3/8!(B)$);
\coordinate (E) at ($(C)!5/8!(B)$);
\coordinate (F) at ($(C)!1/2!(B)$);
\coordinate (G) at ($(E)!1!-90:(F)$);
\coordinate (H) at ($(D)!1!90:(F)$);
\coordinate (I) at ($(F)!1!90:(E)$);
\coordinate [label=above:$J$](J) at ($(F)!1/2!(I)$);
%vector coordinates
\coordinate [label=left:$K$] (K) at ($(A)!1/4!(C)$);

\draw (D) -- (E) -- (G) -- (H) -- cycle;
\draw (F) -- (J);
\draw (F) -- (K);

\path plot[mark=*] coordinates {(J)};

\coordinate (L) at ($(G)!1/2!(E)$);                 %% <--- added
\draw[-latex] (J) -- (L);                           %% <--- added
\draw[-latex] (J) -- (K-|J)node[below]{$mg$};       %% <--- added

%draw and label triangle
\tkzDrawPolygon(A,B,C)
\tkzMarkAngle(C,B,A)
\tkzLabelAngle[left,pos=1](C,B,A){$\theta$}
\tkzMarkRightAngle(C,A,B)


\end{tikzpicture}
\end{document}

enter image description here

For queries in comments, you can do this

%------ added -----------------
\coordinate (L) at ($(G)!1/2!(E)$);                
\coordinate (M) at (K-|J);
\path
 let \p1 = ($(J) - (M) $),
     \n1 = {veclen(\x1,\y1)}
in 
 coordinate (N) at ($(J)!0.9*\n1!(L)$);    %% change 0.9*\n1 as you wish, \n1 is length of mg 
\draw[-latex] (J) -- (N);
\draw[-latex] (J) -- (M)node[below]{$mg$}; 

\tkzMarkAngle[size=4mm](M,J,N) 
\tkzLabelAngle[below,pos=0.4](N,J,M){$\alpha$}

%----- upto here --------------- 

enter image description here

Related Question