9

I want to draw triangle ABC so that the measure of the angle at B is 75 degrees. I use \coordinate (A) at (0,0); to put vertex A at the origin, and I use \coordinate (B) at (60:6); to position vertex B. How do I declare a point C on the horizontal line through A so that the angle at B is 75 degrees?

I placed point S on line segment AB. I want to place T on BC so that angle AST is 110 degrees. (This involves the same procedure as positioning point C.)

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}

\begin{document}


\begin{tikzpicture}

\coordinate (A) at (0,0);
\coordinate (B) at (60:6);
\draw (A) -- (B);

%These commands have vertex C placed on the horizontal line through A so that angle ABC is $30^{\circ}$.
\coordinate (P) at (0,5);
\path[name path=horizontal] (A) -- (P);
%\coordintate (Q) at 

%These commands are to inscribe a triangle in $\triangle{ABC}$.
\node[circle,fill,inner sep=1.5pt,outer sep=0pt,label={left:$S$}] at ($(A)!0.75!(B)$) {};

\end{tikzpicture}
\end{document}
Adelyn
  • 3,373
  • is this a duplicate http://tex.stackexchange.com/questions/173250/simple-way-to-draw-a-triangle-with-one-side-and-two-angles-given – percusse May 06 '15 at 17:15
  • @ percusse I am looking at the code that Ignasi gave at the web site that you referenced. Since I am learning to use TikZ, I would like to draw the triangle by instructing TikZ to calculate vertex C so that it is a point on the horizontal line through A and so that angle ABC is 75 degrees. – Adelyn May 06 '15 at 17:50
  • @percusse I tried the following commands to position C on the horizontal line through A so that angle ABC is 75 degrees. – Adelyn May 06 '15 at 18:16
  • \path[name path=leg] (B)--++(-45:5cm); – Adelyn May 06 '15 at 18:16
  • \coordinate[name intersections={of=horizontal and leg,by=C}]; – Adelyn May 06 '15 at 18:16
  • \node[circle,fill,inner sep=1.5pt,outer sep=0pt,label={right:$C$}] at (C) {C}; – Adelyn May 06 '15 at 18:16
  • TikZ could not compile it. – Adelyn May 06 '15 at 18:16
  • 1
    with calc and intersections libraries you can do \coordinate[label=225:$A$] (a) at (0,0); \coordinate[label=90:$B$] (b) at (60:6); \path[overlay,name path=horz] (a) -- ++(10,0); \path[overlay,name path=ang] (b) -- ($(b)!2!75:(a)$); \draw[name intersections={of=horz and ang,name=i}] (a) -- (b) -- (i-1) coordinate[label=-45:$C$] (c)-- cycle; – percusse May 06 '15 at 20:19
  • @percusse Does the command \path[overlay,name path=ang] (b) -- ($(b)!2!75:(a)$); draw a line segment through b that is twice as long as the line segment between a and b? Do you not care how long it is because you just want to be sure that it intersects line "horz"? – Adelyn May 07 '15 at 01:09
  • @percusse Why do you have "i - 1" in the command \draw[name intersections={of=horz and ang,name=i}] (a) -- (b) -- (i-1) coordinate[label=-45:$C$] (c)-- cycle;? – Adelyn May 07 '15 at 01:09
  • 1
    Yes I want it to be long enough so there is definitely an intersection. overlay makes sure that the bounding box is not affected by these. i-1 is the computed intersection name that is assigned automatically. – percusse May 07 '15 at 07:48
  • @percusse I have some questions about that last command. With the option [name intersections={of=horz and ang,name=i}], you are labeling as "i" the point that is the intersection of "horz" and "ang." This intersection is the point that will be labeled "C." Right? From (i-1) coordinate[label=-45:$C$], though, it seems to me, that vertex C will be put at i-1. If i is the label for a point, what is i - 1? This command has a cycle drawn and the last point in the cycle is c, but its coordinates are not declared in previous commands. What are its coordinates? – Adelyn May 07 '15 at 15:18
  • @percusse The code draws the triangle that I want, but I don't know how to implement it. I tried i - 1 instead of i-1 and got an error. – Adelyn May 07 '15 at 15:20

4 Answers4

8

Edit: I have slightly modified the code in order to have more precise angles and calculation of T on the BC side. Additionally, now it uses the original AB side length provided in the OP (which was 60:6).

I used \tkzFindAngle and \tkzGetAngle (loaded by the tkz-euclide package above) to show you the angles (they are automatically calculated).

Output

figure 1

Code

\documentclass[margin=10pt]{standalone}
\usepackage{amsmath,tkz-euclide}
\usepackage{tikz}
\usetkzobj{all}

\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,shapes}

\tikzset{
    myangle/.style={fill=green!20!white, draw=green!50!black,size=.3,opacity=.3},
    intnode/.style={circle,fill=black,inner sep=1pt,outer sep=0pt}
}

\begin{document}
\begin{tikzpicture}

% Drawing the triangle and the coordinates
\draw coordinate[label=left:A] (a) --++(60:6) coordinate[label=above:B] (b);

\path[name path=ac] (a)--++(0:8.5);
\path[name path=bc] (b)--++(-45:8);
\path[name intersections={of = ac and bc, by=c}];
\node[anchor=west] at (c) {C};

\draw[use as bounding box] (a)--(b)--(c)--cycle;

% Drawing the coordinates S and T
\coordinate (s) at ($(a)!0.75!(b)$);

\path[name path=incls] (s) --++ (-10:5);
\path[name path=altbc] (b) -- (c);
\path[name intersections={of = incls and altbc, by=t}]; 

\draw[dashed] (s) -- (t) node[intnode,label={right:{\color{black}\scriptsize $T$}}] (t) {};

% Angles
\tkzFindAngle(a,b,c)
\tkzGetAngle{angleABC};
\FPround\angleABC\angleABC{0}
\tkzFindAngle(c,a,b)
\tkzGetAngle{angleCAB};
\FPround\angleCAB\angleCAB{0}
\tkzFindAngle(b,c,a)
\tkzGetAngle{angleBCA};
\FPround\angleBCA\angleBCA{0}
\tkzFindAngle(a,s,t)
\tkzGetAngle{angleAST};
\FPround\angleAST\angleAST{0}

\tkzMarkAngle[myangle](a,b,c)
\tkzLabelAngle[pos=.4](a,b,c){\tiny $\angleABC^\circ$}

\tkzMarkAngle[myangle](c,a,b)
\tkzLabelAngle[pos=0.5](c,a,b){\tiny $\angleCAB^\circ$}

\tkzMarkAngle[myangle](b,c,a)
\tkzLabelAngle[pos=0.45](b,c,a){\tiny $\angleBCA^\circ$}

\tkzMarkAngle[myangle](a,s,t)
\tkzLabelAngle[pos=0.4](a,s,t){\tiny $\angleAST^\circ$}

\node[intnode,label={left:\scriptsize $S$}] at (s) {};
\end{tikzpicture}
\end{document}
Alenanno
  • 37,338
  • I am looking for a code using just TikZ. Since AB is inclined at an angle of 60 degrees and I want BC to be inclined at an angle of 75 degrees, there must be a command to draw a line segment at an angle of -45 degrees with respect to the right side of the horizontal line through B. (The angle that AB makes with the horizontal line through B with respect to the right side is 60 degrees by corresponding angles, 60 + 75 = 135, and 180 - 135 = 45.) – Adelyn May 06 '15 at 19:45
  • @Adelyn This uses just Tikz. The tkz-euclide package is to draw the angles. :) – Alenanno May 06 '15 at 19:48
  • @Alenanno, it will be look better if you define the \node s after angles definition. It conflicts the green and black conflict. –  May 06 '15 at 19:49
  • @Alenanno I got three other codes for drawing this triangle, but I would like to understand what you did. You have \draw coordinate(a) --++ (60:2.9cm) coordinate[label=above:B] (b); as the first command. Is the first coordinate always put at the origin? Why do you use 2.9cm? I had 3cm. The command you have draws a line segment 2.9cm inclined at an angle of 60 degrees. The command \draw coordinate (a) --++ (0:4cm) coordinate[label=right:C] (c); draws a horizontal line segment rightwards through a 4cm long. – Adelyn May 06 '15 at 23:41
  • @Alenanno What does \draw[use as bounding box] (a)--(b)--(c)--cycle; do? I would have said that it makes the display of the triangle to be limited to the triangle and any features inside the triangle ... but the nodes are all outside the triangle. – Adelyn May 06 '15 at 23:49
  • @Alenanno You position point S three-quarters of the way from A to B with the command \coordinate (s) at ($(a)!0.75!(b)$);, and you position a point T 1.2cm from S along a line through S and incline 10 degrees below the horizontal line through S with the command \draw[dashed] (s) --++ (-10:1.2cm) (t) {};;. Why did you specify 1.2cm? Is this where the option use as bounding box is used? Why do you have two semicolons at the end of this command? – Adelyn May 06 '15 at 23:58
  • @Adelyn the bounding box is needed to trim extra white borders, not to cut everything outside of it, if I understood it properly. The lengths of the sides are tweaked in order for the correct angles to show. Since you listed the angles as requirements, I changed the length of the sides. If you increase/decrease the length, the angles will change as a consequence, of course. – Alenanno May 07 '15 at 00:00
  • @Adelyn the length of that is to reach the other side. It's late now but I'm sure there is a better way to handle it, I'll look into it tomorrow. The double semicolon is a remnant of me working on the code, delete one of them. I'll edit the answer tomorrow to fix some issues like that, I can't right now. – Alenanno May 07 '15 at 00:06
  • @Adelyn I have improved the code a bit, see the changes. Now your original AB length is restored (60:6) and the angles should be more precise. – Alenanno May 07 '15 at 09:41
  • @Alenanno It seems to me that TikZ should not round in making any of the angles of the triangle. I am not really concerned if the measure of the angle at B is 74.75 degrees or 75 degrees ... but, from the code, the measure of the angle at B should be 75 degrees! Since the sum of the angles of a triangle is 180 degrees, the measure of the angle at C should be 45 degrees! I don't know why you say "more precise." – Adelyn May 07 '15 at 14:17
  • @Alenanno Another member of this site offered the following code. It gives me the triangle that I want, but I have several questions on the last command. Maybe you can answer these questions for me. I will give you his code here. \coordinate[label=225:$A$] (a) at (0,0); \coordinate[label=90:$B$] (b) at (60:6); \path[overlay,name path=horz] (a) -- ++(10,0); \path[overlay,name path=ang] (b) -- ($(b)!2!75:(a)$);\draw[name intersections={of=horz and ang,name=i}] (a) -- (b) -- (i-1) coordinate[label=-45:$C$] (c)-- cycle;` – Adelyn May 07 '15 at 18:00
  • @Alenanno Here are my questions regarding the last command. With the option [name intersections={of=horz and ang,name=i}], "i" is the label for the point that is the intersection of "horz" and "ang." This intersection is the point that will be labeled "C." Right? From (i-1) coordinate[label=-45:$C$], though, it seems to me, that vertex C will be put at i-1. If i is the label for a point, what is i - 1? This command has a cycle drawn and the last point in the cycle is c, but its coordinates are not declared in previous commands. What are its coordinates? – Adelyn May 07 '15 at 18:04
  • @Adelyn You should ask percusse to be sure, but I think it works like this: intersections are named like that, so i-1 is equivalent to i. Also (i-1) coordinate[label=-45:$C$] (c) means that c = i-1. But ask percusse to be sure. :) – Alenanno May 07 '15 at 18:55
  • @Alenanno I removed name=i from [name intersections={of=horz and ang,name=i}] and replaced i-1 with intersection-1 in (i-1) coordinate[label=-45:$C$] (c) and TikZ compiled the code to draw the triangle that I wanted. – Adelyn May 07 '15 at 20:34
  • @Adelyn Now I see and it's expected. By removing name=i you basically set the name to the default (which is intersection-1 since it's the first intersection you're calculating). – Alenanno May 07 '15 at 20:40
  • @Alenanno Yep. Is there any difference in between [name intersections={of=horz and ang,name=i}] and [name intersections={of=horz and ang,by=i}]? – Adelyn May 07 '15 at 21:13
  • Great answer. Unfortunately, right now this gives an error "Undefined control sequence \usetkzobj". Any thoughts? Thanks! – PatrickT Feb 16 '24 at 19:16
6

For the record and for whom it may interest, here is a quick way to do it with MetaPost.

I've made use of MetaPost's trademark implicit linear equation solver. For example, the following line

C = whatever[A, A+right] = whatever[B, A rotatedaround (B, 75)];

tells MetaPost almost literally that C must be somewhere on the horizontal straight line starting from A and somewhere on the straight line starting from B and forming an angle of 75 degree with (BA). It is enough for it to determine exactly where C lies.

T is computed the same way:

T = whatever[B, C] = whatever[S, A rotatedaround (S, 110)];

Here is the complete code, included in a LuaLaTeX program for typesetting convenience.

\documentclass[border=2mm]{standalone}
\usepackage{luamplib, gensymb}
  \mplibsetformat{metafun}
  \mplibtextextlabel{enable}
\begin{document}
  \begin{mplibcode}
    pair A, B, C, S, T; numeric u;
    u = cm; A = origin; B = 6u*dir 60; S = .75[A, B];
    C = whatever[A, A+right] = whatever[B, A rotatedaround (B, 75)];
    T = whatever[B, C] = whatever[S, A rotatedaround (S, 110)];
    beginfig(1);
      draw A--B--C--cycle;
      draw S--T dashed evenly;
      label.llft("$A$", A); label.top("$B$", B); label.lrt("$C$", C);
      label.lft("$S$", S); label.urt("$T$", T);
      anglelength := 12bp;
      draw anglebetween(A--C, A--B, "$60\degree$");
      draw anglebetween(B--A, B--C, "$75\degree$");
      draw anglebetween(S--A, S--T, "$110\degree$");
    endfig;
  \end{mplibcode}
\end{document}

enter image description here

For those who wish to use standalone MetaPost, here is an adequate version, producing the same result.

input latexmp
setupLaTeXMP(textextlabel=enable, mode=rerun, packages="gensymb");
pair A, B, C, S, T; numeric u;
u = cm; A = origin; B = 6u*dir 60; S = .75[A, B];
C = whatever[A, A+right] = whatever[B, A rotatedaround (B, 75)];
T = whatever[B, C] = whatever[S, A rotatedaround (S, 110)];
beginfig(1);
  draw A--B--C--cycle;
  draw S--T dashed evenly;
  label.llft("$A$", A); label.top("$B$", B); label.lrt("$C$", C);
  label.lft("$S$", S); label.urt("$T$", T);
  anglelength := 12bp;
  draw anglebetween(A--C, A--B, "$60\degree$");
  draw anglebetween(B--A, B--C, "$75\degree$");
  draw anglebetween(S--A, S--T, "$110\degree$");
  setbounds currentpicture to boundingbox currentpicture enlarged 2mm;
endfig;
end.

From this code, and with a Unix command line (I don't know anything about Windows!), a PDF figure can be obtained with these instructions, assuming that the code has been saved under the name mytriangle.mp:

mpost --mem=metafun mytriangle.mp
mptopdf mytriangle.1
Franck Pastor
  • 18,756
5

For straight lines, I'd use the intersection cs: or its implicit version intersection of <p1>--<p2> and <p3>--<p4>.

The turn key is useful for more complicated examples/calculations.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{angles,quotes}
\begin{document}
\begin{tikzpicture}[declare function={alpha=60; beta=75; sigma=110;}]
\path (0,0) coordinate (A) + (right:1) coordinate (aC)
      (A) -- coordinate[pos=.75] (S) ++ (alpha:6) coordinate (B)
                                  ([turn]beta:-1) coordinate (bC)
      (A) -- (S) ([turn]sigma:-1) coordinate (s);

\draw (A) -- (B) -- (intersection of A--aC and B--bC) coordinate (C) -- cycle;
\draw[dashed] (S) -- (intersection of S--s and B--bC) coordinate (T);

\foreach \p/\dir in {A/180, B/90, C/0, S/alpha+90, T/45}
  \node[circle,inner sep=+1pt,fill,label=\dir:$\p$] at (\p) {};

\foreach \angle/\val in {C--A--B/alpha,          A--B--C/beta,
                         B--C--A/180-beta-alpha, A--S--T/sigma}
  \pic["\scriptsize\pgfmathparse{\val}$\pgfmathprintnumber{\pgfmathresult}^\circ$",
      draw, angle radius=7.5mm] {angle/.expanded=\angle};
\end{tikzpicture}
\end{document}

Output

enter image description here

Qrrbrbirlbel
  • 119,821
  • I am getting familiar with using TikZ. Maybe later I will use \foreach commands. This is the first time that I am seeing the option declare function. – Adelyn May 11 '15 at 11:28
4

Here is another TikZ suggestion:

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,intersections,angles, quotes}
\begin{document}
\begin{tikzpicture}[
  dot/.style={circle,fill,inner sep=1.5pt,outer sep=0pt},
  constr/.style={overlay},% % help lines not enlarge the bounding box
  %constr/.append style={draw=red,very thick},% to show the help lines
]
%
\newcommand\dist{6}% distance A to B
\newcommand\CAB{60}% angle CAB
\newcommand\ABC{75}% angle ABC
\newcommand\AST{110}% angle AST
\newcommand\factor{3}% factor for the construction of the help lines
%
\coordinate[label=left:$A$] (A) at (0,0);
\coordinate[label=above:$B$] (B) at (\CAB:\dist);
\coordinate (S) at ($(A)!0.75!(B)$);
% C
\path[name path=horizontal,constr](A) -- ++({\factor*\dist},0);
\path[name path=leg,constr] (B) -- ++({\CAB-180+\ABC}:\factor*\dist);
\path[name intersections={of=horizontal and leg,by=C}](C)coordinate[label=right:$C$];
% T
\path[name path=st,constr] (S) -- ++({\CAB-180+\AST}:\factor*\dist);
\coordinate[name intersections={of=st and leg,by=T}];
% angles
\pic foreach \t/\a/\b/\c in {\CAB/C/A/B,\ABC/A/B/C,\AST/A/S/T}
  ["$\t^\circ$",draw=orange!80!black,angle radius=1.1cm,fill=orange!20]
  {angle=\a--\b--\c};
% triangle
\draw(A)--(B)--(C)--cycle;
\draw[blue](S)node[dot,label=left:$S$]{} -- (T)node[dot,label=right:$T$]{};
\end{tikzpicture}
\end{document}

enter image description here

This works because the angle CAB is given.


But maybe A is not at the origin or B is not given by polarcoordinates. Then we can use the turn key as explained in the pgfmanual in subsection "Rotational Relative Coordinates" (in the current manual version on page 142):

The effect of this key is to locally shift the coordinate system so that the last point reached is at the origin and the coordinate system is "turned" so that the x-axis points in the direction of a tangent entering the last point.

So I define an additional coordinate H1 by

\path[constr](A)--(B)--([turn]{-180+\ABC}:\dist)coordinate(H1);

That means: go from A to B and then change your direction relatively by -180°+\ABC° (in the example -180+75=-105) and go \dist (in the example 18) units. The resulting angle ABH1 is then \ABC° (in the example 75°).

In the following example A is at (-2,0), B is at (4,5), C is on the horizontal line through A and the angle at B is again 75° and at S 110°.

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,intersections,angles, quotes}
\begin{document}
\begin{tikzpicture}[
  dot/.style={circle,fill,inner sep=1.5pt,outer sep=0pt},
  constr/.style={overlay},% % help lines not enlarge the bounding box
 % constr/.append style={draw=red,very thick},% to show the help lines
]
%
\newcommand\dist{18}% distance A to B
\newcommand\ABC{75}% angle ABC
\newcommand\AST{110}% angle AST
%
\coordinate[label=left:$A$] (A) at (-2,0);
\coordinate[label=above:$B$] (B) at (4,5);
\coordinate (S) at ($(A)!0.75!(B)$);
% C
\path[name path=horizontal,constr](A) -- ++(\dist,0);
\path[constr](A)--(B)--([turn]{-180+\ABC}:\dist)coordinate(H1);
\path[name path=leg,constr] (B)--(H1);
\path[name intersections={of=horizontal and leg,by=C}](C)coordinate[label=right:$C$];
% T
\path[constr](A) -- (S) -- ([turn]{-180+\AST}:\dist)coordinate(H2);
\path[name path=st,constr] (S) -- (H2);
\coordinate[name intersections={of=st and leg,by=T}];
%% angles
\pic foreach \t/\a/\b/\c in {\ABC/A/B/C,\AST/A/S/T}
  ["$\t^\circ$",draw=purple!80!black,angle radius=1.1cm,fill=purple!20]
  {angle=\a--\b--\c};
%% triangle
\draw(A)--(B)--(C)--cycle;
\draw[blue](S)node[dot,label=left:$S$]{} -- (T)node[dot,label=right:$T$]{};
\end{tikzpicture}
\end{document}

enter image description here

esdd
  • 85,675
  • I am going to replace "\dist" and "\factor" with "6" and "3," respectively, in my discussion of your code. With the command \path[name path=horizontal](A) -- ++({3*6},0); you label a path from the origin to the point (18,0). I am going to replace "\beta" with "75." I have not seen the option turn used until I saw your command \path[name path=leg] (B) -- ([turn]{-180+75}:3*6);. What are the coordinates of the point indicated by ([turn]-105:18)? – Adelyn May 07 '15 at 00:17
  • 1
    @Adelyn I have removed turn from my first example and added a second example to show what turn does. – esdd May 07 '15 at 09:39
  • I apologize for the delayed response. I have had three people reply with different codes - all of which are very nice. I think that I understand what you mean by the [turn] option. I will refer to "Rotational Relative Coordinates" in the manual before making any further comment on your code. – Adelyn May 07 '15 at 17:52