Tikz: Perpendicular FROM a line
Clash Royale CLAN TAG#URR8PPP
With tikz-pgf
, I can draw a perpendicular from a point to a line. Is there a robust method to draw a perpendicular from a point? For example, in the following code, say I want to raise a perpendicular, from a specific point on line BC
outwards.
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc
begindocument
begintikzpicture
coordinate (A) at (0,0);
coordinate (B) at (2,4);
coordinate (C) at (8,0);
draw(A)--(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);
node[label=below left:$A$] at (A) ;
node[label=above:$B$] at (B) ;
node[label=below right:$C$] at (C) ;
endtikzpicture
enddocument
tikz-pgf
add a comment |
With tikz-pgf
, I can draw a perpendicular from a point to a line. Is there a robust method to draw a perpendicular from a point? For example, in the following code, say I want to raise a perpendicular, from a specific point on line BC
outwards.
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc
begindocument
begintikzpicture
coordinate (A) at (0,0);
coordinate (B) at (2,4);
coordinate (C) at (8,0);
draw(A)--(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);
node[label=below left:$A$] at (A) ;
node[label=above:$B$] at (B) ;
node[label=below right:$C$] at (C) ;
endtikzpicture
enddocument
tikz-pgf
You changed the position of the starting point in your question : so to draw from a pointP
onBC
you can use(P) -- ++(2/sqrt(13),3/sqrt(13))
(or to for faster compile(P) -- ++(0.5547001962252291,0.8320502943378437)
), or you can use as I saidcalc
to draw(P) -- ($(P)!1cm!90:(C)$)
.
– Kpym
Feb 23 at 10:02
@Kpym I edited it because in the given form the suggested approach was obvious. I am looking for a general solution.
– blackened
Feb 23 at 10:03
Hmm! I was being a fool, again. Say the point onBC
is the midpoint. I can simply define that coordinate as, say,coordinate (P) at ($(B)!0.5!(C)$)
. Then I can do,draw (P)--($(P)!0.5!90:(C)$)
.
– blackened
Feb 23 at 10:18
@blackened ordraw[red, thick] (P) -- ($(A)!(P)!(C)$);
as you already did for your line from B.
– CarLaTeX
Feb 23 at 10:29
add a comment |
With tikz-pgf
, I can draw a perpendicular from a point to a line. Is there a robust method to draw a perpendicular from a point? For example, in the following code, say I want to raise a perpendicular, from a specific point on line BC
outwards.
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc
begindocument
begintikzpicture
coordinate (A) at (0,0);
coordinate (B) at (2,4);
coordinate (C) at (8,0);
draw(A)--(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);
node[label=below left:$A$] at (A) ;
node[label=above:$B$] at (B) ;
node[label=below right:$C$] at (C) ;
endtikzpicture
enddocument
tikz-pgf
With tikz-pgf
, I can draw a perpendicular from a point to a line. Is there a robust method to draw a perpendicular from a point? For example, in the following code, say I want to raise a perpendicular, from a specific point on line BC
outwards.
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc
begindocument
begintikzpicture
coordinate (A) at (0,0);
coordinate (B) at (2,4);
coordinate (C) at (8,0);
draw(A)--(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);
node[label=below left:$A$] at (A) ;
node[label=above:$B$] at (B) ;
node[label=below right:$C$] at (C) ;
endtikzpicture
enddocument
tikz-pgf
tikz-pgf
edited Feb 23 at 9:52
blackened
asked Feb 23 at 9:35
blackenedblackened
1,650714
1,650714
You changed the position of the starting point in your question : so to draw from a pointP
onBC
you can use(P) -- ++(2/sqrt(13),3/sqrt(13))
(or to for faster compile(P) -- ++(0.5547001962252291,0.8320502943378437)
), or you can use as I saidcalc
to draw(P) -- ($(P)!1cm!90:(C)$)
.
– Kpym
Feb 23 at 10:02
@Kpym I edited it because in the given form the suggested approach was obvious. I am looking for a general solution.
– blackened
Feb 23 at 10:03
Hmm! I was being a fool, again. Say the point onBC
is the midpoint. I can simply define that coordinate as, say,coordinate (P) at ($(B)!0.5!(C)$)
. Then I can do,draw (P)--($(P)!0.5!90:(C)$)
.
– blackened
Feb 23 at 10:18
@blackened ordraw[red, thick] (P) -- ($(A)!(P)!(C)$);
as you already did for your line from B.
– CarLaTeX
Feb 23 at 10:29
add a comment |
You changed the position of the starting point in your question : so to draw from a pointP
onBC
you can use(P) -- ++(2/sqrt(13),3/sqrt(13))
(or to for faster compile(P) -- ++(0.5547001962252291,0.8320502943378437)
), or you can use as I saidcalc
to draw(P) -- ($(P)!1cm!90:(C)$)
.
– Kpym
Feb 23 at 10:02
@Kpym I edited it because in the given form the suggested approach was obvious. I am looking for a general solution.
– blackened
Feb 23 at 10:03
Hmm! I was being a fool, again. Say the point onBC
is the midpoint. I can simply define that coordinate as, say,coordinate (P) at ($(B)!0.5!(C)$)
. Then I can do,draw (P)--($(P)!0.5!90:(C)$)
.
– blackened
Feb 23 at 10:18
@blackened ordraw[red, thick] (P) -- ($(A)!(P)!(C)$);
as you already did for your line from B.
– CarLaTeX
Feb 23 at 10:29
You changed the position of the starting point in your question : so to draw from a point
P
on BC
you can use (P) -- ++(2/sqrt(13),3/sqrt(13))
(or to for faster compile (P) -- ++(0.5547001962252291,0.8320502943378437)
), or you can use as I said calc
to draw (P) -- ($(P)!1cm!90:(C)$)
.– Kpym
Feb 23 at 10:02
You changed the position of the starting point in your question : so to draw from a point
P
on BC
you can use (P) -- ++(2/sqrt(13),3/sqrt(13))
(or to for faster compile (P) -- ++(0.5547001962252291,0.8320502943378437)
), or you can use as I said calc
to draw (P) -- ($(P)!1cm!90:(C)$)
.– Kpym
Feb 23 at 10:02
@Kpym I edited it because in the given form the suggested approach was obvious. I am looking for a general solution.
– blackened
Feb 23 at 10:03
@Kpym I edited it because in the given form the suggested approach was obvious. I am looking for a general solution.
– blackened
Feb 23 at 10:03
Hmm! I was being a fool, again. Say the point on
BC
is the midpoint. I can simply define that coordinate as, say, coordinate (P) at ($(B)!0.5!(C)$)
. Then I can do, draw (P)--($(P)!0.5!90:(C)$)
.– blackened
Feb 23 at 10:18
Hmm! I was being a fool, again. Say the point on
BC
is the midpoint. I can simply define that coordinate as, say, coordinate (P) at ($(B)!0.5!(C)$)
. Then I can do, draw (P)--($(P)!0.5!90:(C)$)
.– blackened
Feb 23 at 10:18
@blackened or
draw[red, thick] (P) -- ($(A)!(P)!(C)$);
as you already did for your line from B.– CarLaTeX
Feb 23 at 10:29
@blackened or
draw[red, thick] (P) -- ($(A)!(P)!(C)$);
as you already did for your line from B.– CarLaTeX
Feb 23 at 10:29
add a comment |
5 Answers
5
active
oldest
votes
I just wrote such a style in this answer. I slightly changed the syntax, so you need to say
draw[blue,vert=of (B)--(C) at (3,0)];
to draw a vertical line at (3,0)
that goes all the way until it hits BC
. And I added vert outwards
which is just a wrapper of the distance modifiers (see section 13.5.4 The Syntax of Distance Modifiers of the pgfmanual), and can be used as
draw[blue,vert outwards=from ($(B)!0.3!(C)$) by 3cm on line to (C)];
MWE
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarycalc
begindocument
begintikzpicture[vert/.style args=of #1 at #2insert path=%
#2 -- (intersection cs:first
line=#1, second line=#2--($#2+(0,10)$)) ,
vert outwards/.style args=from #1 by #2 on line to #3insert path=
#1 -- ($#1!#2!90:#3$)
]
coordinate (A) at (0,0);
coordinate (B) at (2,4);
coordinate (C) at (8,0);
draw(A)--(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);
node[label=below left:$A$] at (A) ;
node[label=above:$B$] at (B) ;
node[label=below right:$C$] at (C) ;
draw[blue,vert=of (B)--(C) at (3,0)];
draw[blue,vert outwards=from ($(B)!0.3!(C)$) by 3cm on line to (C)];
endtikzpicture
enddocument
add a comment |
if you willing to define specific point on line (B)--(C)
with its relative position, than you can write your mwe as following simple solution:
documentclass[tikz,border=10pt]standalone
begindocument
begintikzpicture
coordinate[label=below left:$A$] (A) at (0,0);
coordinate[label=above:$B$] (B) at (2,4);
coordinate[label=below right:$C$] (C) at (8,0);
draw(A)--(B)-- coordinate[pos=0.3] (aux) % <--- coordinate of the point
(C)--cycle;
draw[red] (aux) -- (aux |- A);
endtikzpicture
enddocument
add a comment |
Answer to the first version of the question
With intersections
you can give a name to your triangle path, then build a "fake path" from (4,0) to a point after the intersection with the triangle (you don't need to calculate it exactly, see name path=riga
and draw it to understand what I'm saying) and name it, then you can draw a line between the intersections with your triangle and your "fake path".
Answer to the second version of the question
If you want to start from a point on BC
, you can use coordinate (P) at ($(B)!.5!(C)$);
with any value you want instead of .5
and do like you did for the line from B
(see the thick red line in my MWE).
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc, intersections
begindocument
begintikzpicture
coordinate[label=below left:$A$] (A) at (0,0);
coordinate[label=above:$B$] (B) at (2,4);
coordinate[label=below right:$C$] (C) at (8,0);
draw[name path=trian](A) --(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);
path [name path=riga] (4,0) -- ++(0,3);
path [name intersections=of=trian and riga];
draw (intersection-1) -- (intersection-2);
coordinate (P) at ($(B)!.5!(C)$);
draw[red, thick] (P) -- ($(A)!(P)!(C)$);
endtikzpicture
enddocument
I understood the question as OP want a line starting from som point onBC
and going perpendicular toBC
outward some distance. (ok now I see that the question has been edited).
– hpekristiansen
Feb 23 at 10:02
add a comment |
Sorry, not tikz. I understand @hpekris's idea.
documentclass[pstricks,border=10pt]standalone
usepackagepst-eucl
begindocument
foreach i in .3,.5,.7
beginpspicture[PointSymbol=none,linejoin=1](0,-1)(8,4)
pnodes(0,0)A(2,4)B(8,0)C(4,0)I
psline(A)(B)(C)(A)
pstHomO[HomCoef=i,PosAngle=75]BC[M]
pstProjection[PosAngle=-90]ACB[H]
pstProjection[PosAngle=-90]ACM[M']
pcline(M)(M')
pcline(B)(H)
endpspicture
enddocument
1
Good, please could you decrease the velocity of the animation :-)?
– Sebastiano
Feb 23 at 10:34
add a comment |
Another PSTricks solution just for comparison purposes.
I provide some possible tricks but you can remove the parts that you don't want.
documentclass[pstricks,border=12pt]standalone
usepackagepst-eucl
begindocument
foreach i in 1,2,3%
beginpspicture(8,5)
pstTriangle(1,1)A(7,1)B(3,4)C
psline(C)(C
enddocument
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%2f476296%2ftikz-perpendicular-from-a-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
I just wrote such a style in this answer. I slightly changed the syntax, so you need to say
draw[blue,vert=of (B)--(C) at (3,0)];
to draw a vertical line at (3,0)
that goes all the way until it hits BC
. And I added vert outwards
which is just a wrapper of the distance modifiers (see section 13.5.4 The Syntax of Distance Modifiers of the pgfmanual), and can be used as
draw[blue,vert outwards=from ($(B)!0.3!(C)$) by 3cm on line to (C)];
MWE
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarycalc
begindocument
begintikzpicture[vert/.style args=of #1 at #2insert path=%
#2 -- (intersection cs:first
line=#1, second line=#2--($#2+(0,10)$)) ,
vert outwards/.style args=from #1 by #2 on line to #3insert path=
#1 -- ($#1!#2!90:#3$)
]
coordinate (A) at (0,0);
coordinate (B) at (2,4);
coordinate (C) at (8,0);
draw(A)--(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);
node[label=below left:$A$] at (A) ;
node[label=above:$B$] at (B) ;
node[label=below right:$C$] at (C) ;
draw[blue,vert=of (B)--(C) at (3,0)];
draw[blue,vert outwards=from ($(B)!0.3!(C)$) by 3cm on line to (C)];
endtikzpicture
enddocument
add a comment |
I just wrote such a style in this answer. I slightly changed the syntax, so you need to say
draw[blue,vert=of (B)--(C) at (3,0)];
to draw a vertical line at (3,0)
that goes all the way until it hits BC
. And I added vert outwards
which is just a wrapper of the distance modifiers (see section 13.5.4 The Syntax of Distance Modifiers of the pgfmanual), and can be used as
draw[blue,vert outwards=from ($(B)!0.3!(C)$) by 3cm on line to (C)];
MWE
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarycalc
begindocument
begintikzpicture[vert/.style args=of #1 at #2insert path=%
#2 -- (intersection cs:first
line=#1, second line=#2--($#2+(0,10)$)) ,
vert outwards/.style args=from #1 by #2 on line to #3insert path=
#1 -- ($#1!#2!90:#3$)
]
coordinate (A) at (0,0);
coordinate (B) at (2,4);
coordinate (C) at (8,0);
draw(A)--(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);
node[label=below left:$A$] at (A) ;
node[label=above:$B$] at (B) ;
node[label=below right:$C$] at (C) ;
draw[blue,vert=of (B)--(C) at (3,0)];
draw[blue,vert outwards=from ($(B)!0.3!(C)$) by 3cm on line to (C)];
endtikzpicture
enddocument
add a comment |
I just wrote such a style in this answer. I slightly changed the syntax, so you need to say
draw[blue,vert=of (B)--(C) at (3,0)];
to draw a vertical line at (3,0)
that goes all the way until it hits BC
. And I added vert outwards
which is just a wrapper of the distance modifiers (see section 13.5.4 The Syntax of Distance Modifiers of the pgfmanual), and can be used as
draw[blue,vert outwards=from ($(B)!0.3!(C)$) by 3cm on line to (C)];
MWE
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarycalc
begindocument
begintikzpicture[vert/.style args=of #1 at #2insert path=%
#2 -- (intersection cs:first
line=#1, second line=#2--($#2+(0,10)$)) ,
vert outwards/.style args=from #1 by #2 on line to #3insert path=
#1 -- ($#1!#2!90:#3$)
]
coordinate (A) at (0,0);
coordinate (B) at (2,4);
coordinate (C) at (8,0);
draw(A)--(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);
node[label=below left:$A$] at (A) ;
node[label=above:$B$] at (B) ;
node[label=below right:$C$] at (C) ;
draw[blue,vert=of (B)--(C) at (3,0)];
draw[blue,vert outwards=from ($(B)!0.3!(C)$) by 3cm on line to (C)];
endtikzpicture
enddocument
I just wrote such a style in this answer. I slightly changed the syntax, so you need to say
draw[blue,vert=of (B)--(C) at (3,0)];
to draw a vertical line at (3,0)
that goes all the way until it hits BC
. And I added vert outwards
which is just a wrapper of the distance modifiers (see section 13.5.4 The Syntax of Distance Modifiers of the pgfmanual), and can be used as
draw[blue,vert outwards=from ($(B)!0.3!(C)$) by 3cm on line to (C)];
MWE
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarycalc
begindocument
begintikzpicture[vert/.style args=of #1 at #2insert path=%
#2 -- (intersection cs:first
line=#1, second line=#2--($#2+(0,10)$)) ,
vert outwards/.style args=from #1 by #2 on line to #3insert path=
#1 -- ($#1!#2!90:#3$)
]
coordinate (A) at (0,0);
coordinate (B) at (2,4);
coordinate (C) at (8,0);
draw(A)--(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);
node[label=below left:$A$] at (A) ;
node[label=above:$B$] at (B) ;
node[label=below right:$C$] at (C) ;
draw[blue,vert=of (B)--(C) at (3,0)];
draw[blue,vert outwards=from ($(B)!0.3!(C)$) by 3cm on line to (C)];
endtikzpicture
enddocument
edited Feb 23 at 13:30
answered Feb 23 at 13:20
marmotmarmot
110k5136255
110k5136255
add a comment |
add a comment |
if you willing to define specific point on line (B)--(C)
with its relative position, than you can write your mwe as following simple solution:
documentclass[tikz,border=10pt]standalone
begindocument
begintikzpicture
coordinate[label=below left:$A$] (A) at (0,0);
coordinate[label=above:$B$] (B) at (2,4);
coordinate[label=below right:$C$] (C) at (8,0);
draw(A)--(B)-- coordinate[pos=0.3] (aux) % <--- coordinate of the point
(C)--cycle;
draw[red] (aux) -- (aux |- A);
endtikzpicture
enddocument
add a comment |
if you willing to define specific point on line (B)--(C)
with its relative position, than you can write your mwe as following simple solution:
documentclass[tikz,border=10pt]standalone
begindocument
begintikzpicture
coordinate[label=below left:$A$] (A) at (0,0);
coordinate[label=above:$B$] (B) at (2,4);
coordinate[label=below right:$C$] (C) at (8,0);
draw(A)--(B)-- coordinate[pos=0.3] (aux) % <--- coordinate of the point
(C)--cycle;
draw[red] (aux) -- (aux |- A);
endtikzpicture
enddocument
add a comment |
if you willing to define specific point on line (B)--(C)
with its relative position, than you can write your mwe as following simple solution:
documentclass[tikz,border=10pt]standalone
begindocument
begintikzpicture
coordinate[label=below left:$A$] (A) at (0,0);
coordinate[label=above:$B$] (B) at (2,4);
coordinate[label=below right:$C$] (C) at (8,0);
draw(A)--(B)-- coordinate[pos=0.3] (aux) % <--- coordinate of the point
(C)--cycle;
draw[red] (aux) -- (aux |- A);
endtikzpicture
enddocument
if you willing to define specific point on line (B)--(C)
with its relative position, than you can write your mwe as following simple solution:
documentclass[tikz,border=10pt]standalone
begindocument
begintikzpicture
coordinate[label=below left:$A$] (A) at (0,0);
coordinate[label=above:$B$] (B) at (2,4);
coordinate[label=below right:$C$] (C) at (8,0);
draw(A)--(B)-- coordinate[pos=0.3] (aux) % <--- coordinate of the point
(C)--cycle;
draw[red] (aux) -- (aux |- A);
endtikzpicture
enddocument
answered Feb 23 at 10:19
ZarkoZarko
127k868167
127k868167
add a comment |
add a comment |
Answer to the first version of the question
With intersections
you can give a name to your triangle path, then build a "fake path" from (4,0) to a point after the intersection with the triangle (you don't need to calculate it exactly, see name path=riga
and draw it to understand what I'm saying) and name it, then you can draw a line between the intersections with your triangle and your "fake path".
Answer to the second version of the question
If you want to start from a point on BC
, you can use coordinate (P) at ($(B)!.5!(C)$);
with any value you want instead of .5
and do like you did for the line from B
(see the thick red line in my MWE).
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc, intersections
begindocument
begintikzpicture
coordinate[label=below left:$A$] (A) at (0,0);
coordinate[label=above:$B$] (B) at (2,4);
coordinate[label=below right:$C$] (C) at (8,0);
draw[name path=trian](A) --(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);
path [name path=riga] (4,0) -- ++(0,3);
path [name intersections=of=trian and riga];
draw (intersection-1) -- (intersection-2);
coordinate (P) at ($(B)!.5!(C)$);
draw[red, thick] (P) -- ($(A)!(P)!(C)$);
endtikzpicture
enddocument
I understood the question as OP want a line starting from som point onBC
and going perpendicular toBC
outward some distance. (ok now I see that the question has been edited).
– hpekristiansen
Feb 23 at 10:02
add a comment |
Answer to the first version of the question
With intersections
you can give a name to your triangle path, then build a "fake path" from (4,0) to a point after the intersection with the triangle (you don't need to calculate it exactly, see name path=riga
and draw it to understand what I'm saying) and name it, then you can draw a line between the intersections with your triangle and your "fake path".
Answer to the second version of the question
If you want to start from a point on BC
, you can use coordinate (P) at ($(B)!.5!(C)$);
with any value you want instead of .5
and do like you did for the line from B
(see the thick red line in my MWE).
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc, intersections
begindocument
begintikzpicture
coordinate[label=below left:$A$] (A) at (0,0);
coordinate[label=above:$B$] (B) at (2,4);
coordinate[label=below right:$C$] (C) at (8,0);
draw[name path=trian](A) --(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);
path [name path=riga] (4,0) -- ++(0,3);
path [name intersections=of=trian and riga];
draw (intersection-1) -- (intersection-2);
coordinate (P) at ($(B)!.5!(C)$);
draw[red, thick] (P) -- ($(A)!(P)!(C)$);
endtikzpicture
enddocument
I understood the question as OP want a line starting from som point onBC
and going perpendicular toBC
outward some distance. (ok now I see that the question has been edited).
– hpekristiansen
Feb 23 at 10:02
add a comment |
Answer to the first version of the question
With intersections
you can give a name to your triangle path, then build a "fake path" from (4,0) to a point after the intersection with the triangle (you don't need to calculate it exactly, see name path=riga
and draw it to understand what I'm saying) and name it, then you can draw a line between the intersections with your triangle and your "fake path".
Answer to the second version of the question
If you want to start from a point on BC
, you can use coordinate (P) at ($(B)!.5!(C)$);
with any value you want instead of .5
and do like you did for the line from B
(see the thick red line in my MWE).
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc, intersections
begindocument
begintikzpicture
coordinate[label=below left:$A$] (A) at (0,0);
coordinate[label=above:$B$] (B) at (2,4);
coordinate[label=below right:$C$] (C) at (8,0);
draw[name path=trian](A) --(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);
path [name path=riga] (4,0) -- ++(0,3);
path [name intersections=of=trian and riga];
draw (intersection-1) -- (intersection-2);
coordinate (P) at ($(B)!.5!(C)$);
draw[red, thick] (P) -- ($(A)!(P)!(C)$);
endtikzpicture
enddocument
Answer to the first version of the question
With intersections
you can give a name to your triangle path, then build a "fake path" from (4,0) to a point after the intersection with the triangle (you don't need to calculate it exactly, see name path=riga
and draw it to understand what I'm saying) and name it, then you can draw a line between the intersections with your triangle and your "fake path".
Answer to the second version of the question
If you want to start from a point on BC
, you can use coordinate (P) at ($(B)!.5!(C)$);
with any value you want instead of .5
and do like you did for the line from B
(see the thick red line in my MWE).
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc, intersections
begindocument
begintikzpicture
coordinate[label=below left:$A$] (A) at (0,0);
coordinate[label=above:$B$] (B) at (2,4);
coordinate[label=below right:$C$] (C) at (8,0);
draw[name path=trian](A) --(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);
path [name path=riga] (4,0) -- ++(0,3);
path [name intersections=of=trian and riga];
draw (intersection-1) -- (intersection-2);
coordinate (P) at ($(B)!.5!(C)$);
draw[red, thick] (P) -- ($(A)!(P)!(C)$);
endtikzpicture
enddocument
edited Feb 23 at 10:52
answered Feb 23 at 9:48
CarLaTeXCarLaTeX
33.8k551138
33.8k551138
I understood the question as OP want a line starting from som point onBC
and going perpendicular toBC
outward some distance. (ok now I see that the question has been edited).
– hpekristiansen
Feb 23 at 10:02
add a comment |
I understood the question as OP want a line starting from som point onBC
and going perpendicular toBC
outward some distance. (ok now I see that the question has been edited).
– hpekristiansen
Feb 23 at 10:02
I understood the question as OP want a line starting from som point on
BC
and going perpendicular to BC
outward some distance. (ok now I see that the question has been edited).– hpekristiansen
Feb 23 at 10:02
I understood the question as OP want a line starting from som point on
BC
and going perpendicular to BC
outward some distance. (ok now I see that the question has been edited).– hpekristiansen
Feb 23 at 10:02
add a comment |
Sorry, not tikz. I understand @hpekris's idea.
documentclass[pstricks,border=10pt]standalone
usepackagepst-eucl
begindocument
foreach i in .3,.5,.7
beginpspicture[PointSymbol=none,linejoin=1](0,-1)(8,4)
pnodes(0,0)A(2,4)B(8,0)C(4,0)I
psline(A)(B)(C)(A)
pstHomO[HomCoef=i,PosAngle=75]BC[M]
pstProjection[PosAngle=-90]ACB[H]
pstProjection[PosAngle=-90]ACM[M']
pcline(M)(M')
pcline(B)(H)
endpspicture
enddocument
1
Good, please could you decrease the velocity of the animation :-)?
– Sebastiano
Feb 23 at 10:34
add a comment |
Sorry, not tikz. I understand @hpekris's idea.
documentclass[pstricks,border=10pt]standalone
usepackagepst-eucl
begindocument
foreach i in .3,.5,.7
beginpspicture[PointSymbol=none,linejoin=1](0,-1)(8,4)
pnodes(0,0)A(2,4)B(8,0)C(4,0)I
psline(A)(B)(C)(A)
pstHomO[HomCoef=i,PosAngle=75]BC[M]
pstProjection[PosAngle=-90]ACB[H]
pstProjection[PosAngle=-90]ACM[M']
pcline(M)(M')
pcline(B)(H)
endpspicture
enddocument
1
Good, please could you decrease the velocity of the animation :-)?
– Sebastiano
Feb 23 at 10:34
add a comment |
Sorry, not tikz. I understand @hpekris's idea.
documentclass[pstricks,border=10pt]standalone
usepackagepst-eucl
begindocument
foreach i in .3,.5,.7
beginpspicture[PointSymbol=none,linejoin=1](0,-1)(8,4)
pnodes(0,0)A(2,4)B(8,0)C(4,0)I
psline(A)(B)(C)(A)
pstHomO[HomCoef=i,PosAngle=75]BC[M]
pstProjection[PosAngle=-90]ACB[H]
pstProjection[PosAngle=-90]ACM[M']
pcline(M)(M')
pcline(B)(H)
endpspicture
enddocument
Sorry, not tikz. I understand @hpekris's idea.
documentclass[pstricks,border=10pt]standalone
usepackagepst-eucl
begindocument
foreach i in .3,.5,.7
beginpspicture[PointSymbol=none,linejoin=1](0,-1)(8,4)
pnodes(0,0)A(2,4)B(8,0)C(4,0)I
psline(A)(B)(C)(A)
pstHomO[HomCoef=i,PosAngle=75]BC[M]
pstProjection[PosAngle=-90]ACB[H]
pstProjection[PosAngle=-90]ACM[M']
pcline(M)(M')
pcline(B)(H)
endpspicture
enddocument
edited Feb 23 at 10:58
answered Feb 23 at 10:18
chishimutojichishimutoji
7331323
7331323
1
Good, please could you decrease the velocity of the animation :-)?
– Sebastiano
Feb 23 at 10:34
add a comment |
1
Good, please could you decrease the velocity of the animation :-)?
– Sebastiano
Feb 23 at 10:34
1
1
Good, please could you decrease the velocity of the animation :-)?
– Sebastiano
Feb 23 at 10:34
Good, please could you decrease the velocity of the animation :-)?
– Sebastiano
Feb 23 at 10:34
add a comment |
Another PSTricks solution just for comparison purposes.
I provide some possible tricks but you can remove the parts that you don't want.
documentclass[pstricks,border=12pt]standalone
usepackagepst-eucl
begindocument
foreach i in 1,2,3%
beginpspicture(8,5)
pstTriangle(1,1)A(7,1)B(3,4)C
psline(C)(C
enddocument
add a comment |
Another PSTricks solution just for comparison purposes.
I provide some possible tricks but you can remove the parts that you don't want.
documentclass[pstricks,border=12pt]standalone
usepackagepst-eucl
begindocument
foreach i in 1,2,3%
beginpspicture(8,5)
pstTriangle(1,1)A(7,1)B(3,4)C
psline(C)(C
enddocument
add a comment |
Another PSTricks solution just for comparison purposes.
I provide some possible tricks but you can remove the parts that you don't want.
documentclass[pstricks,border=12pt]standalone
usepackagepst-eucl
begindocument
foreach i in 1,2,3%
beginpspicture(8,5)
pstTriangle(1,1)A(7,1)B(3,4)C
psline(C)(C
enddocument
Another PSTricks solution just for comparison purposes.
I provide some possible tricks but you can remove the parts that you don't want.
documentclass[pstricks,border=12pt]standalone
usepackagepst-eucl
begindocument
foreach i in 1,2,3%
beginpspicture(8,5)
pstTriangle(1,1)A(7,1)B(3,4)C
psline(C)(C
enddocument
answered Feb 23 at 13:44
The Inventor of GodThe Inventor of God
4,93611142
4,93611142
add a comment |
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%2f476296%2ftikz-perpendicular-from-a-line%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
You changed the position of the starting point in your question : so to draw from a point
P
onBC
you can use(P) -- ++(2/sqrt(13),3/sqrt(13))
(or to for faster compile(P) -- ++(0.5547001962252291,0.8320502943378437)
), or you can use as I saidcalc
to draw(P) -- ($(P)!1cm!90:(C)$)
.– Kpym
Feb 23 at 10:02
@Kpym I edited it because in the given form the suggested approach was obvious. I am looking for a general solution.
– blackened
Feb 23 at 10:03
Hmm! I was being a fool, again. Say the point on
BC
is the midpoint. I can simply define that coordinate as, say,coordinate (P) at ($(B)!0.5!(C)$)
. Then I can do,draw (P)--($(P)!0.5!90:(C)$)
.– blackened
Feb 23 at 10:18
@blackened or
draw[red, thick] (P) -- ($(A)!(P)!(C)$);
as you already did for your line from B.– CarLaTeX
Feb 23 at 10:29