TransWikia.com

changing length of line, tikz

TeX - LaTeX Asked on August 3, 2021

In the code below, I want to change the length of the bottom line- the red arrow, see image attached. I am aware how to do this in a usual line of code, but this piece of code (copied and pasted to create a perpendicular line, I am not sure off, I have tried length=3, length=3cm , after the ‘<->’ but it renders an error. Many thanks !
enter image description here

documentclass[journal]{IEEEtran}
usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps}
usepackage{graphicx}

usepackage[T1]{fontenc}
usepackage{amsfonts}
%usepackage[pdftex]{graphicx}
% Comment the following line to NOT allow the usage of umlauts
usepackage{pgfgantt}
usetikzlibrary{angles,calc,math}
usepackage{tkz-euclide}
usepackage{pdflscape}

% Start the docu

usepackage{xcolor}
usetikzlibrary{positioning}

usepackage{amsmath}
usepackage{tikz}

bibliographystyle{IEEEtran}

%pagestyle{fancyplain}




 begin{document}



begin{figure}
centerline
{begin{tikzpicture}
draw[dashed] (0,0)--(7,3);
draw[dashed] (7,3)--(7,0);
draw [dashed] (7,0)--(0,0);
node[right]  at (0.6,0.1) {$theta$};
draw[<->, ultra thin,gray](7.1,2.7)--(0.1,-0.28);
node [below] at (3.6, 1.3) {$L_p$};


draw [->, ultra thick](7,3)--(6.6,2.8) ;
%^ x axis

%addgravitylabel
draw[->, ultra thick] (3,4)--(3,3.5);
node[left] at (3,4.0){$bf{g}$};


node [below] at (6.8,2.9) {X};

% S(X) 
draw [thick ] (4,1.75) to [out=90,in=180] (5,2.15);
to [out=0,in=180] (5.5,2.0) to [out=0,in=-135] (6.0,2.6);
draw [thick] (6,2.6) to [out=90,in=180] (7,3.05);
draw[thick](5,2.15)--(6,2.6);
draw[thick](4,1.75)--(0,0);





%F(X,T)
draw [thick, ] (0,1) to [out=90,in=180] (1,1.45)
to [out=0,in=180] (1.5,1.37) to [out=0,in=-135] (2.0,1.9) ;
draw [,thick, ] (2,1.9) to [out=90,in=180] (3,2.35)
to [out=0,in=180] (3.5,2.25) to [out=0,in=-135] (4.0,2.75);
draw [,thick, ] (4,2.75) to [out=90,in=180] (5,3.2)
to [out=0,in=180] (5.5,3.1) to [out=0,in=-135] (6.0,3.6);
draw [,thick,] (6,3.6) to [out=90,in=180] (7,4.05);



draw [thin, ] (2.5,0) to [out=90,in=0] (2,0.85);


%length and depth

%free-surfacelabel
%inclineplanelabel 

draw[ <-, thin] (6,2.6)--(5.5,4.3);
draw[<-, thin] (1,1.45)--(-0.7,2.8);
node at (5.5,4.3) {$S(X)$};
%node[above]
node at  (-0.8,3) {$F(X,T)$};

% Z AXIS To change
draw [->,ultra thick] (7,3)--(6.7,3.5);
node[right]  at (7,3.3) {Z};


% PERPENDICULAR QUESTION HERE !!
%draw [<->,thin] (3.6,1.5)--(3.55,2.28) ;
node[right] at (4.5,2.7) {H(X,T)};

%node[color=blue] at (5.4,2.3){dfd};
  %tkzDefLine[orthogonal=through C](C,O);
  %tkzDrawLine[,add = .6 and 0.02,color=black](O,tkzPointResult);

coordinate (O) at (5.7,2.5) ;
coordinate (E) at (5.4,2.35);


draw[thick] (O)--(E) node[pos=3.0,color=white](x){a} ;
draw[red,<->,thin,transform canvas={rotate around={90:(x)}}] (O) -- (E) ;





end{tikzpicture}}

end{figure}
end{document}

One Answer

You need to have a look at I've just been asked to write a minimal working example (MWE), what is that?

I try to guess what you want and rewrite all of your code. Specifically, I use calc - you can find explanation in the manual. It is also perfectly acceptable to use explicit coordinates.

documentclass[tikz, border=1cm]{standalone}
usepackage{tikz-dimline}
usetikzlibrary{angles, quotes, calc}
begin{document}
begin{tikzpicture}[>=latex]
coordinate (A) at (0,0);
coordinate (B) at (7,3);
coordinate (C) at (7,0);

draw[dashed] (A)--(B)--(C)--cycle;
draw pic["$theta$", draw, angle radius=2cm, angle eccentricity=0.8] {angle=C--A--B};
dimline{ ($ (B)!1cm!90:(A) $) } { ($ (A)!1cm!-90:(B) $) } {$L_P$};
draw[->, ultra thick] (B) -- node[right]{$vec Z$} ($ (B)!0.5cm!-90:(A) $);
draw[->, ultra thick] (B) -- node[below]{$vec X$} ($ (B)!0.5cm!(A) $);
draw[->, ultra thick] (3,4) -- node[left] {$vec g$} (3,3.5);    
draw [thick ] ($(A)+(0,0.1) $) -- (4,1.8) to [out=90,in=180] (5,2.2) -- (5.9,2.6) to [out=90,in=180] (6.8,3);
draw [thick, ] (0,1) to [out=90,in=180] (1,1.45) to [out=0,in=180] (1.5,1.37) to [out=0,in=-135] (2,1.9) to [out=90,in=180] (3,2.35) to [out=0,in=180] (3.5,2.25) to [out=0,in=-135] (4,2.75) to [out=90,in=180] (5,3.2) to [out=0,in=180] (5.5,3.1) to [out=0,in=-135] (6,3.6) to [out=90,in=180] (7,4.05);
draw[ <-] (6.2,2.7)--(5.5,4.3) node[above] {$S(X)$};
draw[<-] (0.5,1.5)--(-0,2.8) node[above] {$F(X,T)$};
draw[red,<->] ($ ($ (B)!2.5cm!(A) $)!0.3cm!90:(B) $) -- ($ ($ (B)!2.5cm!(A) $)!1.1cm!90:(B) $);
node[right] at (4.4,2.7) {H(X,T)};
end{tikzpicture}
end{document}

Drawing

Edit:

From calc

The general meaning of ⟨a⟩!⟨factor⟩!⟨angle⟩:⟨b⟩ is: “First, consider the line from ⟨a⟩ to ⟨b⟩. Then rotate this line by ⟨angle⟩ around the point ⟨a⟩. Then the two endpoints of this line will be ⟨a⟩ and some point ⟨c⟩. Use this point ⟨c⟩ for the subsequent computation, namely the partway computation.”

-much easier just to look at examples p. 150 in the manual.

Answered by hpekristiansen on August 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP