Using functions like sine, cosine and tangent to calculate coordinates in Tikz
Clash Royale CLAN TAG#URR8PPP
I am learning TikZ with the pgfmanual. The example given is as follows:
I have achieved the following so far:
The code is as follows:
documentclassarticle
usepackagetikz
tikzsethelp lines/.style=very thin
tikzsetMy Grid/.style=help lines,color=blue!50
begindocument
begintikzpicture
draw[My Grid] (-4,-4) grid (4,4);
draw (-5,0) node[left] $(-5,0)$ -- (5,0) node[right] $(5,0)$;
draw (0,-5) node[below] $(0,-5)$ -- (0,5) node[above] $(0,5)$;
draw (0,0) circle [radius=3cm];
shadedraw[left color=gray, right color=green, draw=green!50!black] (0,0) -- (0.75,0) arc [start angle=0, end angle=30, radius=1cm] -- cycle;
draw[red, very thick] (30:3cm) -- (2.6,0);
draw [very thick,orange] (3,0) -- (3,1.7);
endtikzpicture
enddocument
To achieve the intersection of the slope and tangent, pgfmanual uses the concept of path and intersections library which is very confusing.
Is there an easier way to tell the system to draw a line from point A to sin(30) as point B and to draw tangent of the angle proportionately instead of using direct numbers.
Please suggest alternative apart from intersections, polar coordinates and paths. Because the pgfmanual already uses them which is hard to understand.
tikz-pgf intersections
add a comment |
I am learning TikZ with the pgfmanual. The example given is as follows:
I have achieved the following so far:
The code is as follows:
documentclassarticle
usepackagetikz
tikzsethelp lines/.style=very thin
tikzsetMy Grid/.style=help lines,color=blue!50
begindocument
begintikzpicture
draw[My Grid] (-4,-4) grid (4,4);
draw (-5,0) node[left] $(-5,0)$ -- (5,0) node[right] $(5,0)$;
draw (0,-5) node[below] $(0,-5)$ -- (0,5) node[above] $(0,5)$;
draw (0,0) circle [radius=3cm];
shadedraw[left color=gray, right color=green, draw=green!50!black] (0,0) -- (0.75,0) arc [start angle=0, end angle=30, radius=1cm] -- cycle;
draw[red, very thick] (30:3cm) -- (2.6,0);
draw [very thick,orange] (3,0) -- (3,1.7);
endtikzpicture
enddocument
To achieve the intersection of the slope and tangent, pgfmanual uses the concept of path and intersections library which is very confusing.
Is there an easier way to tell the system to draw a line from point A to sin(30) as point B and to draw tangent of the angle proportionately instead of using direct numbers.
Please suggest alternative apart from intersections, polar coordinates and paths. Because the pgfmanual already uses them which is hard to understand.
tikz-pgf intersections
May be If you specify exactly what is hard for you to understand someone will try to explain it to you
– Hafid Boukhoulda
Feb 23 at 8:14
@hafid The slope lines and connecting the tangent for the time being
– subham soni
Feb 23 at 8:16
Do you need to usecos(30)
andtan(30)
to indicate point coordinates instead of(2.6,0)
and(3,1.7)
– Hafid Boukhoulda
Feb 23 at 8:23
Yes @hafid. That is exactly the requirement.
– subham soni
Feb 23 at 8:27
I think your approach is simpler than working with explicitsin
andcos
functions. E.g. the red line can be drawn likedraw[red, very thick] (30:3cm) -- (0,0-|30:3cm);
, where the last coordinate is the projection of the first one ony=0
.
– marmot
Feb 23 at 14:11
add a comment |
I am learning TikZ with the pgfmanual. The example given is as follows:
I have achieved the following so far:
The code is as follows:
documentclassarticle
usepackagetikz
tikzsethelp lines/.style=very thin
tikzsetMy Grid/.style=help lines,color=blue!50
begindocument
begintikzpicture
draw[My Grid] (-4,-4) grid (4,4);
draw (-5,0) node[left] $(-5,0)$ -- (5,0) node[right] $(5,0)$;
draw (0,-5) node[below] $(0,-5)$ -- (0,5) node[above] $(0,5)$;
draw (0,0) circle [radius=3cm];
shadedraw[left color=gray, right color=green, draw=green!50!black] (0,0) -- (0.75,0) arc [start angle=0, end angle=30, radius=1cm] -- cycle;
draw[red, very thick] (30:3cm) -- (2.6,0);
draw [very thick,orange] (3,0) -- (3,1.7);
endtikzpicture
enddocument
To achieve the intersection of the slope and tangent, pgfmanual uses the concept of path and intersections library which is very confusing.
Is there an easier way to tell the system to draw a line from point A to sin(30) as point B and to draw tangent of the angle proportionately instead of using direct numbers.
Please suggest alternative apart from intersections, polar coordinates and paths. Because the pgfmanual already uses them which is hard to understand.
tikz-pgf intersections
I am learning TikZ with the pgfmanual. The example given is as follows:
I have achieved the following so far:
The code is as follows:
documentclassarticle
usepackagetikz
tikzsethelp lines/.style=very thin
tikzsetMy Grid/.style=help lines,color=blue!50
begindocument
begintikzpicture
draw[My Grid] (-4,-4) grid (4,4);
draw (-5,0) node[left] $(-5,0)$ -- (5,0) node[right] $(5,0)$;
draw (0,-5) node[below] $(0,-5)$ -- (0,5) node[above] $(0,5)$;
draw (0,0) circle [radius=3cm];
shadedraw[left color=gray, right color=green, draw=green!50!black] (0,0) -- (0.75,0) arc [start angle=0, end angle=30, radius=1cm] -- cycle;
draw[red, very thick] (30:3cm) -- (2.6,0);
draw [very thick,orange] (3,0) -- (3,1.7);
endtikzpicture
enddocument
To achieve the intersection of the slope and tangent, pgfmanual uses the concept of path and intersections library which is very confusing.
Is there an easier way to tell the system to draw a line from point A to sin(30) as point B and to draw tangent of the angle proportionately instead of using direct numbers.
Please suggest alternative apart from intersections, polar coordinates and paths. Because the pgfmanual already uses them which is hard to understand.
tikz-pgf intersections
tikz-pgf intersections
edited Feb 23 at 9:22
Hafid Boukhoulda
4,5741625
4,5741625
asked Feb 23 at 8:04
subham sonisubham soni
4,40783184
4,40783184
May be If you specify exactly what is hard for you to understand someone will try to explain it to you
– Hafid Boukhoulda
Feb 23 at 8:14
@hafid The slope lines and connecting the tangent for the time being
– subham soni
Feb 23 at 8:16
Do you need to usecos(30)
andtan(30)
to indicate point coordinates instead of(2.6,0)
and(3,1.7)
– Hafid Boukhoulda
Feb 23 at 8:23
Yes @hafid. That is exactly the requirement.
– subham soni
Feb 23 at 8:27
I think your approach is simpler than working with explicitsin
andcos
functions. E.g. the red line can be drawn likedraw[red, very thick] (30:3cm) -- (0,0-|30:3cm);
, where the last coordinate is the projection of the first one ony=0
.
– marmot
Feb 23 at 14:11
add a comment |
May be If you specify exactly what is hard for you to understand someone will try to explain it to you
– Hafid Boukhoulda
Feb 23 at 8:14
@hafid The slope lines and connecting the tangent for the time being
– subham soni
Feb 23 at 8:16
Do you need to usecos(30)
andtan(30)
to indicate point coordinates instead of(2.6,0)
and(3,1.7)
– Hafid Boukhoulda
Feb 23 at 8:23
Yes @hafid. That is exactly the requirement.
– subham soni
Feb 23 at 8:27
I think your approach is simpler than working with explicitsin
andcos
functions. E.g. the red line can be drawn likedraw[red, very thick] (30:3cm) -- (0,0-|30:3cm);
, where the last coordinate is the projection of the first one ony=0
.
– marmot
Feb 23 at 14:11
May be If you specify exactly what is hard for you to understand someone will try to explain it to you
– Hafid Boukhoulda
Feb 23 at 8:14
May be If you specify exactly what is hard for you to understand someone will try to explain it to you
– Hafid Boukhoulda
Feb 23 at 8:14
@hafid The slope lines and connecting the tangent for the time being
– subham soni
Feb 23 at 8:16
@hafid The slope lines and connecting the tangent for the time being
– subham soni
Feb 23 at 8:16
Do you need to use
cos(30)
and tan(30)
to indicate point coordinates instead of (2.6,0)
and (3,1.7)
– Hafid Boukhoulda
Feb 23 at 8:23
Do you need to use
cos(30)
and tan(30)
to indicate point coordinates instead of (2.6,0)
and (3,1.7)
– Hafid Boukhoulda
Feb 23 at 8:23
Yes @hafid. That is exactly the requirement.
– subham soni
Feb 23 at 8:27
Yes @hafid. That is exactly the requirement.
– subham soni
Feb 23 at 8:27
I think your approach is simpler than working with explicit
sin
and cos
functions. E.g. the red line can be drawn like draw[red, very thick] (30:3cm) -- (0,0-|30:3cm);
, where the last coordinate is the projection of the first one on y=0
.– marmot
Feb 23 at 14:11
I think your approach is simpler than working with explicit
sin
and cos
functions. E.g. the red line can be drawn like draw[red, very thick] (30:3cm) -- (0,0-|30:3cm);
, where the last coordinate is the projection of the first one on y=0
.– marmot
Feb 23 at 14:11
add a comment |
2 Answers
2
active
oldest
votes
Since in cos(30)
and tan(30)
there are parentheses you must put these functions inside curly brackets
documentclassarticle
usepackagetikz
usetikzlibraryangles,quotes
tikzsethelp lines/.style=very thin
tikzsetMy Grid/.style=help lines,color=blue!50
begindocument
begintikzpicture
draw[My Grid] (-4,-4) grid (4,4);
draw (-5,0) node[left] $(-5,0)$ -- (5,0) node[right] $(5,0)$;
draw (0,-5) node[below] $(0,-5)$ -- (0,5) node[above] $(0,5)$;
draw (0,0) circle [radius=3cm];
% shadedraw[left color=gray, right color=green, draw=green!50!black]
% (0,0) -- (0.75,0) arc [start angle=0, end angle=30, radius=0.75cm] -- cycle;
coordinate(O)at(0,0);
draw[red, very thick] (30:3cm)coordinate(A)
--(3*cos(30),0)coordinate(B);
draw [very thick,orange] (3,0) -- (3,3*tan(30))coordinate(C);
pic[fill=green!50!black,
angle radius=0.75cm,
angle eccentricity=1.2,
"(alpha)"] angle=B--O--A;
draw (O)--(C);
endtikzpicture
enddocument
Will this ensure that the length is actual value when computed as well or plotted manually with pencil and graph?
– subham soni
Feb 23 at 8:32
@subhamsoni I notice that the green angle is greeter than 30° I suppose you needed to be 30°
– Hafid Boukhoulda
Feb 23 at 8:38
I have mentioned end angle as 30. Is there anything I am missing
– subham soni
Feb 23 at 8:39
@subhamsoni Yes you need the specify the correct radius 0.75 cm and not 1cm since the start point is (0.75,0). Also in Tikz there is another manner to draw angles.
– Hafid Boukhoulda
Feb 23 at 8:43
it would be great if you can share the other way because precision is always better.
– subham soni
Feb 23 at 8:46
|
show 4 more comments
Here is an alternative to Hafid's nice answer, going further into the direction you started. You do not need to use any trigonometric function. Just using polar coordinates and projections is sufficient.
documentclassarticle
usepackagetikz
usetikzlibrarycalc,angles,quotes
tikzsethelp lines/.style=very thin
tikzsetMy Grid/.style=help lines,color=blue!50
begindocument
begintikzpicture
draw[My Grid] (-4,-4) grid (4,4);
draw (-5,0) node[left] $(-5,0)$ -- (5,0) node[right] $(5,0)$;
draw (0,-5) node[below] $(0,-5)$ -- (0,5) node[above] $(0,5)$;
draw (0,0) coordinate (O) circle [radius=3cm];
draw[red, very thick] (30:3cm) coordinate (A)
% (30:3cm) is a polar coordinate with angle 30 (degrees) and radius 3cm
-- (0,0-|A) coordinate(Ax)
% (0,0-|30:3cm) is a point that has the x coordinate of A and y=0
% see https://tex.stackexchange.com/a/401429/121799 for more details
node[midway,left]$sinalpha$;
draw [very thick,orange] (3,0) -- (intersection cs:
first line=(O)--(A),second line=(3,0)--(3,3)) coordinate(A')
% (A') is at the intersections of the lines OA and the vertical line through (3,0)
node[midway,right]$tanalpha$;
pic[fill=green!50,angle radius=1cm,
angle eccentricity=0.6, "$alpha$"] angle=Ax--O--A;
% that's almost a 1-1 copy of what you can find on p. 560 of the manual
draw (O) -- (A');
draw[very thick,blue] (O) -- (Ax) node[midway,below]$cosalpha$;
endtikzpicture
enddocument
Thanks marmot . Can you please add comments to each line of the tikz code which will help me understand better. Especially the relationship between polar coordinates and projection
– subham soni
Feb 23 at 15:12
1
@subhamsoni I added explanations in the comments in the code.
– marmot
Feb 23 at 15:24
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476287%2fusing-functions-like-sine-cosine-and-tangent-to-calculate-coordinates-in-tikz%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Since in cos(30)
and tan(30)
there are parentheses you must put these functions inside curly brackets
documentclassarticle
usepackagetikz
usetikzlibraryangles,quotes
tikzsethelp lines/.style=very thin
tikzsetMy Grid/.style=help lines,color=blue!50
begindocument
begintikzpicture
draw[My Grid] (-4,-4) grid (4,4);
draw (-5,0) node[left] $(-5,0)$ -- (5,0) node[right] $(5,0)$;
draw (0,-5) node[below] $(0,-5)$ -- (0,5) node[above] $(0,5)$;
draw (0,0) circle [radius=3cm];
% shadedraw[left color=gray, right color=green, draw=green!50!black]
% (0,0) -- (0.75,0) arc [start angle=0, end angle=30, radius=0.75cm] -- cycle;
coordinate(O)at(0,0);
draw[red, very thick] (30:3cm)coordinate(A)
--(3*cos(30),0)coordinate(B);
draw [very thick,orange] (3,0) -- (3,3*tan(30))coordinate(C);
pic[fill=green!50!black,
angle radius=0.75cm,
angle eccentricity=1.2,
"(alpha)"] angle=B--O--A;
draw (O)--(C);
endtikzpicture
enddocument
Will this ensure that the length is actual value when computed as well or plotted manually with pencil and graph?
– subham soni
Feb 23 at 8:32
@subhamsoni I notice that the green angle is greeter than 30° I suppose you needed to be 30°
– Hafid Boukhoulda
Feb 23 at 8:38
I have mentioned end angle as 30. Is there anything I am missing
– subham soni
Feb 23 at 8:39
@subhamsoni Yes you need the specify the correct radius 0.75 cm and not 1cm since the start point is (0.75,0). Also in Tikz there is another manner to draw angles.
– Hafid Boukhoulda
Feb 23 at 8:43
it would be great if you can share the other way because precision is always better.
– subham soni
Feb 23 at 8:46
|
show 4 more comments
Since in cos(30)
and tan(30)
there are parentheses you must put these functions inside curly brackets
documentclassarticle
usepackagetikz
usetikzlibraryangles,quotes
tikzsethelp lines/.style=very thin
tikzsetMy Grid/.style=help lines,color=blue!50
begindocument
begintikzpicture
draw[My Grid] (-4,-4) grid (4,4);
draw (-5,0) node[left] $(-5,0)$ -- (5,0) node[right] $(5,0)$;
draw (0,-5) node[below] $(0,-5)$ -- (0,5) node[above] $(0,5)$;
draw (0,0) circle [radius=3cm];
% shadedraw[left color=gray, right color=green, draw=green!50!black]
% (0,0) -- (0.75,0) arc [start angle=0, end angle=30, radius=0.75cm] -- cycle;
coordinate(O)at(0,0);
draw[red, very thick] (30:3cm)coordinate(A)
--(3*cos(30),0)coordinate(B);
draw [very thick,orange] (3,0) -- (3,3*tan(30))coordinate(C);
pic[fill=green!50!black,
angle radius=0.75cm,
angle eccentricity=1.2,
"(alpha)"] angle=B--O--A;
draw (O)--(C);
endtikzpicture
enddocument
Will this ensure that the length is actual value when computed as well or plotted manually with pencil and graph?
– subham soni
Feb 23 at 8:32
@subhamsoni I notice that the green angle is greeter than 30° I suppose you needed to be 30°
– Hafid Boukhoulda
Feb 23 at 8:38
I have mentioned end angle as 30. Is there anything I am missing
– subham soni
Feb 23 at 8:39
@subhamsoni Yes you need the specify the correct radius 0.75 cm and not 1cm since the start point is (0.75,0). Also in Tikz there is another manner to draw angles.
– Hafid Boukhoulda
Feb 23 at 8:43
it would be great if you can share the other way because precision is always better.
– subham soni
Feb 23 at 8:46
|
show 4 more comments
Since in cos(30)
and tan(30)
there are parentheses you must put these functions inside curly brackets
documentclassarticle
usepackagetikz
usetikzlibraryangles,quotes
tikzsethelp lines/.style=very thin
tikzsetMy Grid/.style=help lines,color=blue!50
begindocument
begintikzpicture
draw[My Grid] (-4,-4) grid (4,4);
draw (-5,0) node[left] $(-5,0)$ -- (5,0) node[right] $(5,0)$;
draw (0,-5) node[below] $(0,-5)$ -- (0,5) node[above] $(0,5)$;
draw (0,0) circle [radius=3cm];
% shadedraw[left color=gray, right color=green, draw=green!50!black]
% (0,0) -- (0.75,0) arc [start angle=0, end angle=30, radius=0.75cm] -- cycle;
coordinate(O)at(0,0);
draw[red, very thick] (30:3cm)coordinate(A)
--(3*cos(30),0)coordinate(B);
draw [very thick,orange] (3,0) -- (3,3*tan(30))coordinate(C);
pic[fill=green!50!black,
angle radius=0.75cm,
angle eccentricity=1.2,
"(alpha)"] angle=B--O--A;
draw (O)--(C);
endtikzpicture
enddocument
Since in cos(30)
and tan(30)
there are parentheses you must put these functions inside curly brackets
documentclassarticle
usepackagetikz
usetikzlibraryangles,quotes
tikzsethelp lines/.style=very thin
tikzsetMy Grid/.style=help lines,color=blue!50
begindocument
begintikzpicture
draw[My Grid] (-4,-4) grid (4,4);
draw (-5,0) node[left] $(-5,0)$ -- (5,0) node[right] $(5,0)$;
draw (0,-5) node[below] $(0,-5)$ -- (0,5) node[above] $(0,5)$;
draw (0,0) circle [radius=3cm];
% shadedraw[left color=gray, right color=green, draw=green!50!black]
% (0,0) -- (0.75,0) arc [start angle=0, end angle=30, radius=0.75cm] -- cycle;
coordinate(O)at(0,0);
draw[red, very thick] (30:3cm)coordinate(A)
--(3*cos(30),0)coordinate(B);
draw [very thick,orange] (3,0) -- (3,3*tan(30))coordinate(C);
pic[fill=green!50!black,
angle radius=0.75cm,
angle eccentricity=1.2,
"(alpha)"] angle=B--O--A;
draw (O)--(C);
endtikzpicture
enddocument
edited Feb 23 at 10:54
answered Feb 23 at 8:27
Hafid BoukhouldaHafid Boukhoulda
4,5741625
4,5741625
Will this ensure that the length is actual value when computed as well or plotted manually with pencil and graph?
– subham soni
Feb 23 at 8:32
@subhamsoni I notice that the green angle is greeter than 30° I suppose you needed to be 30°
– Hafid Boukhoulda
Feb 23 at 8:38
I have mentioned end angle as 30. Is there anything I am missing
– subham soni
Feb 23 at 8:39
@subhamsoni Yes you need the specify the correct radius 0.75 cm and not 1cm since the start point is (0.75,0). Also in Tikz there is another manner to draw angles.
– Hafid Boukhoulda
Feb 23 at 8:43
it would be great if you can share the other way because precision is always better.
– subham soni
Feb 23 at 8:46
|
show 4 more comments
Will this ensure that the length is actual value when computed as well or plotted manually with pencil and graph?
– subham soni
Feb 23 at 8:32
@subhamsoni I notice that the green angle is greeter than 30° I suppose you needed to be 30°
– Hafid Boukhoulda
Feb 23 at 8:38
I have mentioned end angle as 30. Is there anything I am missing
– subham soni
Feb 23 at 8:39
@subhamsoni Yes you need the specify the correct radius 0.75 cm and not 1cm since the start point is (0.75,0). Also in Tikz there is another manner to draw angles.
– Hafid Boukhoulda
Feb 23 at 8:43
it would be great if you can share the other way because precision is always better.
– subham soni
Feb 23 at 8:46
Will this ensure that the length is actual value when computed as well or plotted manually with pencil and graph?
– subham soni
Feb 23 at 8:32
Will this ensure that the length is actual value when computed as well or plotted manually with pencil and graph?
– subham soni
Feb 23 at 8:32
@subhamsoni I notice that the green angle is greeter than 30° I suppose you needed to be 30°
– Hafid Boukhoulda
Feb 23 at 8:38
@subhamsoni I notice that the green angle is greeter than 30° I suppose you needed to be 30°
– Hafid Boukhoulda
Feb 23 at 8:38
I have mentioned end angle as 30. Is there anything I am missing
– subham soni
Feb 23 at 8:39
I have mentioned end angle as 30. Is there anything I am missing
– subham soni
Feb 23 at 8:39
@subhamsoni Yes you need the specify the correct radius 0.75 cm and not 1cm since the start point is (0.75,0). Also in Tikz there is another manner to draw angles.
– Hafid Boukhoulda
Feb 23 at 8:43
@subhamsoni Yes you need the specify the correct radius 0.75 cm and not 1cm since the start point is (0.75,0). Also in Tikz there is another manner to draw angles.
– Hafid Boukhoulda
Feb 23 at 8:43
it would be great if you can share the other way because precision is always better.
– subham soni
Feb 23 at 8:46
it would be great if you can share the other way because precision is always better.
– subham soni
Feb 23 at 8:46
|
show 4 more comments
Here is an alternative to Hafid's nice answer, going further into the direction you started. You do not need to use any trigonometric function. Just using polar coordinates and projections is sufficient.
documentclassarticle
usepackagetikz
usetikzlibrarycalc,angles,quotes
tikzsethelp lines/.style=very thin
tikzsetMy Grid/.style=help lines,color=blue!50
begindocument
begintikzpicture
draw[My Grid] (-4,-4) grid (4,4);
draw (-5,0) node[left] $(-5,0)$ -- (5,0) node[right] $(5,0)$;
draw (0,-5) node[below] $(0,-5)$ -- (0,5) node[above] $(0,5)$;
draw (0,0) coordinate (O) circle [radius=3cm];
draw[red, very thick] (30:3cm) coordinate (A)
% (30:3cm) is a polar coordinate with angle 30 (degrees) and radius 3cm
-- (0,0-|A) coordinate(Ax)
% (0,0-|30:3cm) is a point that has the x coordinate of A and y=0
% see https://tex.stackexchange.com/a/401429/121799 for more details
node[midway,left]$sinalpha$;
draw [very thick,orange] (3,0) -- (intersection cs:
first line=(O)--(A),second line=(3,0)--(3,3)) coordinate(A')
% (A') is at the intersections of the lines OA and the vertical line through (3,0)
node[midway,right]$tanalpha$;
pic[fill=green!50,angle radius=1cm,
angle eccentricity=0.6, "$alpha$"] angle=Ax--O--A;
% that's almost a 1-1 copy of what you can find on p. 560 of the manual
draw (O) -- (A');
draw[very thick,blue] (O) -- (Ax) node[midway,below]$cosalpha$;
endtikzpicture
enddocument
Thanks marmot . Can you please add comments to each line of the tikz code which will help me understand better. Especially the relationship between polar coordinates and projection
– subham soni
Feb 23 at 15:12
1
@subhamsoni I added explanations in the comments in the code.
– marmot
Feb 23 at 15:24
add a comment |
Here is an alternative to Hafid's nice answer, going further into the direction you started. You do not need to use any trigonometric function. Just using polar coordinates and projections is sufficient.
documentclassarticle
usepackagetikz
usetikzlibrarycalc,angles,quotes
tikzsethelp lines/.style=very thin
tikzsetMy Grid/.style=help lines,color=blue!50
begindocument
begintikzpicture
draw[My Grid] (-4,-4) grid (4,4);
draw (-5,0) node[left] $(-5,0)$ -- (5,0) node[right] $(5,0)$;
draw (0,-5) node[below] $(0,-5)$ -- (0,5) node[above] $(0,5)$;
draw (0,0) coordinate (O) circle [radius=3cm];
draw[red, very thick] (30:3cm) coordinate (A)
% (30:3cm) is a polar coordinate with angle 30 (degrees) and radius 3cm
-- (0,0-|A) coordinate(Ax)
% (0,0-|30:3cm) is a point that has the x coordinate of A and y=0
% see https://tex.stackexchange.com/a/401429/121799 for more details
node[midway,left]$sinalpha$;
draw [very thick,orange] (3,0) -- (intersection cs:
first line=(O)--(A),second line=(3,0)--(3,3)) coordinate(A')
% (A') is at the intersections of the lines OA and the vertical line through (3,0)
node[midway,right]$tanalpha$;
pic[fill=green!50,angle radius=1cm,
angle eccentricity=0.6, "$alpha$"] angle=Ax--O--A;
% that's almost a 1-1 copy of what you can find on p. 560 of the manual
draw (O) -- (A');
draw[very thick,blue] (O) -- (Ax) node[midway,below]$cosalpha$;
endtikzpicture
enddocument
Thanks marmot . Can you please add comments to each line of the tikz code which will help me understand better. Especially the relationship between polar coordinates and projection
– subham soni
Feb 23 at 15:12
1
@subhamsoni I added explanations in the comments in the code.
– marmot
Feb 23 at 15:24
add a comment |
Here is an alternative to Hafid's nice answer, going further into the direction you started. You do not need to use any trigonometric function. Just using polar coordinates and projections is sufficient.
documentclassarticle
usepackagetikz
usetikzlibrarycalc,angles,quotes
tikzsethelp lines/.style=very thin
tikzsetMy Grid/.style=help lines,color=blue!50
begindocument
begintikzpicture
draw[My Grid] (-4,-4) grid (4,4);
draw (-5,0) node[left] $(-5,0)$ -- (5,0) node[right] $(5,0)$;
draw (0,-5) node[below] $(0,-5)$ -- (0,5) node[above] $(0,5)$;
draw (0,0) coordinate (O) circle [radius=3cm];
draw[red, very thick] (30:3cm) coordinate (A)
% (30:3cm) is a polar coordinate with angle 30 (degrees) and radius 3cm
-- (0,0-|A) coordinate(Ax)
% (0,0-|30:3cm) is a point that has the x coordinate of A and y=0
% see https://tex.stackexchange.com/a/401429/121799 for more details
node[midway,left]$sinalpha$;
draw [very thick,orange] (3,0) -- (intersection cs:
first line=(O)--(A),second line=(3,0)--(3,3)) coordinate(A')
% (A') is at the intersections of the lines OA and the vertical line through (3,0)
node[midway,right]$tanalpha$;
pic[fill=green!50,angle radius=1cm,
angle eccentricity=0.6, "$alpha$"] angle=Ax--O--A;
% that's almost a 1-1 copy of what you can find on p. 560 of the manual
draw (O) -- (A');
draw[very thick,blue] (O) -- (Ax) node[midway,below]$cosalpha$;
endtikzpicture
enddocument
Here is an alternative to Hafid's nice answer, going further into the direction you started. You do not need to use any trigonometric function. Just using polar coordinates and projections is sufficient.
documentclassarticle
usepackagetikz
usetikzlibrarycalc,angles,quotes
tikzsethelp lines/.style=very thin
tikzsetMy Grid/.style=help lines,color=blue!50
begindocument
begintikzpicture
draw[My Grid] (-4,-4) grid (4,4);
draw (-5,0) node[left] $(-5,0)$ -- (5,0) node[right] $(5,0)$;
draw (0,-5) node[below] $(0,-5)$ -- (0,5) node[above] $(0,5)$;
draw (0,0) coordinate (O) circle [radius=3cm];
draw[red, very thick] (30:3cm) coordinate (A)
% (30:3cm) is a polar coordinate with angle 30 (degrees) and radius 3cm
-- (0,0-|A) coordinate(Ax)
% (0,0-|30:3cm) is a point that has the x coordinate of A and y=0
% see https://tex.stackexchange.com/a/401429/121799 for more details
node[midway,left]$sinalpha$;
draw [very thick,orange] (3,0) -- (intersection cs:
first line=(O)--(A),second line=(3,0)--(3,3)) coordinate(A')
% (A') is at the intersections of the lines OA and the vertical line through (3,0)
node[midway,right]$tanalpha$;
pic[fill=green!50,angle radius=1cm,
angle eccentricity=0.6, "$alpha$"] angle=Ax--O--A;
% that's almost a 1-1 copy of what you can find on p. 560 of the manual
draw (O) -- (A');
draw[very thick,blue] (O) -- (Ax) node[midway,below]$cosalpha$;
endtikzpicture
enddocument
edited Feb 23 at 15:23
answered Feb 23 at 15:06
marmotmarmot
110k5136255
110k5136255
Thanks marmot . Can you please add comments to each line of the tikz code which will help me understand better. Especially the relationship between polar coordinates and projection
– subham soni
Feb 23 at 15:12
1
@subhamsoni I added explanations in the comments in the code.
– marmot
Feb 23 at 15:24
add a comment |
Thanks marmot . Can you please add comments to each line of the tikz code which will help me understand better. Especially the relationship between polar coordinates and projection
– subham soni
Feb 23 at 15:12
1
@subhamsoni I added explanations in the comments in the code.
– marmot
Feb 23 at 15:24
Thanks marmot . Can you please add comments to each line of the tikz code which will help me understand better. Especially the relationship between polar coordinates and projection
– subham soni
Feb 23 at 15:12
Thanks marmot . Can you please add comments to each line of the tikz code which will help me understand better. Especially the relationship between polar coordinates and projection
– subham soni
Feb 23 at 15:12
1
1
@subhamsoni I added explanations in the comments in the code.
– marmot
Feb 23 at 15:24
@subhamsoni I added explanations in the comments in the code.
– marmot
Feb 23 at 15:24
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476287%2fusing-functions-like-sine-cosine-and-tangent-to-calculate-coordinates-in-tikz%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
May be If you specify exactly what is hard for you to understand someone will try to explain it to you
– Hafid Boukhoulda
Feb 23 at 8:14
@hafid The slope lines and connecting the tangent for the time being
– subham soni
Feb 23 at 8:16
Do you need to use
cos(30)
andtan(30)
to indicate point coordinates instead of(2.6,0)
and(3,1.7)
– Hafid Boukhoulda
Feb 23 at 8:23
Yes @hafid. That is exactly the requirement.
– subham soni
Feb 23 at 8:27
I think your approach is simpler than working with explicit
sin
andcos
functions. E.g. the red line can be drawn likedraw[red, very thick] (30:3cm) -- (0,0-|30:3cm);
, where the last coordinate is the projection of the first one ony=0
.– marmot
Feb 23 at 14:11