Does a zero-length line with an arrow make sense? Is it a bug?
documentclass[pstricks,border=12pt]{standalone}
usepackage{pstricks-add}
begin{document}
multido{i=0+30}{12}{%
begin{pspicture}(-2,-2)(2,2)
pscircle{1}
pnode(1;i){R}
psset{arrows=->}
psline(R)
psline[linecolor=blue](R|0,0)
psline[linecolor=red](0,0|R)
psset{linecolor=gray,linestyle=dashed,linewidth=0.5pslinewidth,arrows=-,dash=2pt 2pt}
psline(R)(R|0,0)
psline(R)(0,0|R)
end{pspicture}}
end{document}
Does a zero-length line with an arrow make sense? Is it a bug? I hope it is a bug.
If it is not a bug, what is the best way to handle this case using a conditional macro in either TeX or PS level?
Apparently, this feature is also adopted by TikZ.
documentclass[tikz,border=0pt]{standalone}
usepackage{tikz}
begin{document}
tikzpicture
fill[yellow] (-1,-1) -- (-1,1) -- (1,1) -- (1,-1) -- cycle;
draw[->] (0,0)--(0,0);
endtikzpicture
end{document}
tikz-pgf pstricks best-practices
|
show 11 more comments
documentclass[pstricks,border=12pt]{standalone}
usepackage{pstricks-add}
begin{document}
multido{i=0+30}{12}{%
begin{pspicture}(-2,-2)(2,2)
pscircle{1}
pnode(1;i){R}
psset{arrows=->}
psline(R)
psline[linecolor=blue](R|0,0)
psline[linecolor=red](0,0|R)
psset{linecolor=gray,linestyle=dashed,linewidth=0.5pslinewidth,arrows=-,dash=2pt 2pt}
psline(R)(R|0,0)
psline(R)(0,0|R)
end{pspicture}}
end{document}
Does a zero-length line with an arrow make sense? Is it a bug? I hope it is a bug.
If it is not a bug, what is the best way to handle this case using a conditional macro in either TeX or PS level?
Apparently, this feature is also adopted by TikZ.
documentclass[tikz,border=0pt]{standalone}
usepackage{tikz}
begin{document}
tikzpicture
fill[yellow] (-1,-1) -- (-1,1) -- (1,1) -- (1,-1) -- cycle;
draw[->] (0,0)--(0,0);
endtikzpicture
end{document}
tikz-pgf pstricks best-practices
1
Add an epsilon perturbation so that direction is properly defined.
– Aditya
Sep 5 '12 at 4:33
why should this be a bug? If the user defines an arrow then it is drawn.
– Herbert
Sep 5 '12 at 11:54
@Herbert: Because it does not make sense. It will be better if the PSTricks core automatically does nothing for zero-length lines.
– kiss my armpit
Sep 5 '12 at 11:58
that has the user to be decide if it makes sense or not ...
– Herbert
Sep 5 '12 at 12:13
@Herbert: If the line length with an arrow is measured from the tip of the arrow to the tail of the line then a zero-length line should be invisible. :-)
– kiss my armpit
Sep 5 '12 at 12:15
|
show 11 more comments
documentclass[pstricks,border=12pt]{standalone}
usepackage{pstricks-add}
begin{document}
multido{i=0+30}{12}{%
begin{pspicture}(-2,-2)(2,2)
pscircle{1}
pnode(1;i){R}
psset{arrows=->}
psline(R)
psline[linecolor=blue](R|0,0)
psline[linecolor=red](0,0|R)
psset{linecolor=gray,linestyle=dashed,linewidth=0.5pslinewidth,arrows=-,dash=2pt 2pt}
psline(R)(R|0,0)
psline(R)(0,0|R)
end{pspicture}}
end{document}
Does a zero-length line with an arrow make sense? Is it a bug? I hope it is a bug.
If it is not a bug, what is the best way to handle this case using a conditional macro in either TeX or PS level?
Apparently, this feature is also adopted by TikZ.
documentclass[tikz,border=0pt]{standalone}
usepackage{tikz}
begin{document}
tikzpicture
fill[yellow] (-1,-1) -- (-1,1) -- (1,1) -- (1,-1) -- cycle;
draw[->] (0,0)--(0,0);
endtikzpicture
end{document}
tikz-pgf pstricks best-practices
documentclass[pstricks,border=12pt]{standalone}
usepackage{pstricks-add}
begin{document}
multido{i=0+30}{12}{%
begin{pspicture}(-2,-2)(2,2)
pscircle{1}
pnode(1;i){R}
psset{arrows=->}
psline(R)
psline[linecolor=blue](R|0,0)
psline[linecolor=red](0,0|R)
psset{linecolor=gray,linestyle=dashed,linewidth=0.5pslinewidth,arrows=-,dash=2pt 2pt}
psline(R)(R|0,0)
psline(R)(0,0|R)
end{pspicture}}
end{document}
Does a zero-length line with an arrow make sense? Is it a bug? I hope it is a bug.
If it is not a bug, what is the best way to handle this case using a conditional macro in either TeX or PS level?
Apparently, this feature is also adopted by TikZ.
documentclass[tikz,border=0pt]{standalone}
usepackage{tikz}
begin{document}
tikzpicture
fill[yellow] (-1,-1) -- (-1,1) -- (1,1) -- (1,-1) -- cycle;
draw[->] (0,0)--(0,0);
endtikzpicture
end{document}
tikz-pgf pstricks best-practices
tikz-pgf pstricks best-practices
edited Sep 5 '12 at 12:12
kiss my armpit
asked Sep 5 '12 at 3:07
kiss my armpitkiss my armpit
12.7k20170404
12.7k20170404
1
Add an epsilon perturbation so that direction is properly defined.
– Aditya
Sep 5 '12 at 4:33
why should this be a bug? If the user defines an arrow then it is drawn.
– Herbert
Sep 5 '12 at 11:54
@Herbert: Because it does not make sense. It will be better if the PSTricks core automatically does nothing for zero-length lines.
– kiss my armpit
Sep 5 '12 at 11:58
that has the user to be decide if it makes sense or not ...
– Herbert
Sep 5 '12 at 12:13
@Herbert: If the line length with an arrow is measured from the tip of the arrow to the tail of the line then a zero-length line should be invisible. :-)
– kiss my armpit
Sep 5 '12 at 12:15
|
show 11 more comments
1
Add an epsilon perturbation so that direction is properly defined.
– Aditya
Sep 5 '12 at 4:33
why should this be a bug? If the user defines an arrow then it is drawn.
– Herbert
Sep 5 '12 at 11:54
@Herbert: Because it does not make sense. It will be better if the PSTricks core automatically does nothing for zero-length lines.
– kiss my armpit
Sep 5 '12 at 11:58
that has the user to be decide if it makes sense or not ...
– Herbert
Sep 5 '12 at 12:13
@Herbert: If the line length with an arrow is measured from the tip of the arrow to the tail of the line then a zero-length line should be invisible. :-)
– kiss my armpit
Sep 5 '12 at 12:15
1
1
Add an epsilon perturbation so that direction is properly defined.
– Aditya
Sep 5 '12 at 4:33
Add an epsilon perturbation so that direction is properly defined.
– Aditya
Sep 5 '12 at 4:33
why should this be a bug? If the user defines an arrow then it is drawn.
– Herbert
Sep 5 '12 at 11:54
why should this be a bug? If the user defines an arrow then it is drawn.
– Herbert
Sep 5 '12 at 11:54
@Herbert: Because it does not make sense. It will be better if the PSTricks core automatically does nothing for zero-length lines.
– kiss my armpit
Sep 5 '12 at 11:58
@Herbert: Because it does not make sense. It will be better if the PSTricks core automatically does nothing for zero-length lines.
– kiss my armpit
Sep 5 '12 at 11:58
that has the user to be decide if it makes sense or not ...
– Herbert
Sep 5 '12 at 12:13
that has the user to be decide if it makes sense or not ...
– Herbert
Sep 5 '12 at 12:13
@Herbert: If the line length with an arrow is measured from the tip of the arrow to the tail of the line then a zero-length line should be invisible. :-)
– kiss my armpit
Sep 5 '12 at 12:15
@Herbert: If the line length with an arrow is measured from the tip of the arrow to the tail of the line then a zero-length line should be invisible. :-)
– kiss my armpit
Sep 5 '12 at 12:15
|
show 11 more comments
2 Answers
2
active
oldest
votes
With pstricks.tex
from http://archiv.dante.de/~herbert/texnik/tex/generic/pstricks/ psLine
can have only one or two pairs of coordinates. Will later be on CTAN.
documentclass[pstricks,border=12pt]{standalone}
usepackage{pst-node,multido}
begin{document}
multido{i=0+30}{12}{%
begin{pspicture}(-2,-2)(2,2)
pscircle{1}
pnode(1;i){R}
psset{arrows=->}
psLine(R)
psLine[linecolor=blue](R|0,0)
psLine[linecolor=red](0,0|R)
psset{linecolor=gray,linestyle=dashed,linewidth=0.5pslinewidth,arrows=-,dash=2pt 2pt}
psLine(R)(R|0,0)
psLine(R)(0,0|R)
end{pspicture}}
end{document}
Is there another simpler, high level (as opposed to the low level with PSTricks core macro) workaround that I can digest and adopt for my future projects?
– kiss my armpit
Sep 5 '12 at 13:01
add a comment |
In TikZ, you can avoid drawing arrow heads if the last segment of a path has a length of zero by patching the internal pgf@check@for@arrows
macro:
makeatletter
defpgf@check@for@arrows{%
pgf@drawarrowsfalse%
ifxpgf@startarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifxpgf@endarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifdimpgf@shorten@end@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifdimpgf@shorten@start@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifpgf@drawarrows%
pgfsyssoftpath@getcurrentpathpgf@arrowpath%
ifxpgf@arrowpathpgfutil@empty%
pgf@drawarrowsfalse%
else%
pgfprocesscheckclosed{pgf@arrowpath}{pgf@drawarrowsfalse}%
%%% New stuff starts here
% Extract first, second, second last and last points
pgfprocesspathextractpoints{pgf@arrowpath}%
% If the second last and last points are identical ...
ifxpgfpointsecondlastonpathpgfpointlastonpath%
% ... disable the arrow head
pgf@drawarrowsfalse%
fi%
%%% New stuff ends here
fi%
fi%
}
makeatother
documentclass[tikz,border=0pt]{standalone}
usepackage{tikz}
makeatletter
defpgf@check@for@arrows{%
pgf@drawarrowsfalse%
ifxpgf@startarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifxpgf@endarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifdimpgf@shorten@end@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifdimpgf@shorten@start@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifpgf@drawarrows%
pgfsyssoftpath@getcurrentpathpgf@arrowpath%
ifxpgf@arrowpathpgfutil@empty%
pgf@drawarrowsfalse%
else%
pgfprocesscheckclosed{pgf@arrowpath}{pgf@drawarrowsfalse}%
pgfprocesspathextractpoints{pgf@arrowpath}%
ifxpgfpointsecondlastonpathpgfpointlastonpath%
pgf@drawarrowsfalse%
fi%
fi%
fi%
}
makeatother
begin{document}
foreach angle in {0,5,...,355}{%
begin{tikzpicture}[
scale=1.5,
arrow/.style={
-stealth, thick, line cap=round
}
]
fill [white] (-1.02,-1.02) rectangle (1.02, 1.02);
draw [gray, densely dashed] (0:{cos(angle)}) |- (90:{sin(angle)});
draw (0,0) circle [radius=1];
draw [blue, arrow] (0,0) -- (0:{cos(angle)});
draw [red, arrow] (0,0) -- (90:{sin(angle)});
draw [black, arrow] (0,0) -- (angle:1);
end{tikzpicture}%
}
end{document}
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%2f70186%2fdoes-a-zero-length-line-with-an-arrow-make-sense-is-it-a-bug%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
With pstricks.tex
from http://archiv.dante.de/~herbert/texnik/tex/generic/pstricks/ psLine
can have only one or two pairs of coordinates. Will later be on CTAN.
documentclass[pstricks,border=12pt]{standalone}
usepackage{pst-node,multido}
begin{document}
multido{i=0+30}{12}{%
begin{pspicture}(-2,-2)(2,2)
pscircle{1}
pnode(1;i){R}
psset{arrows=->}
psLine(R)
psLine[linecolor=blue](R|0,0)
psLine[linecolor=red](0,0|R)
psset{linecolor=gray,linestyle=dashed,linewidth=0.5pslinewidth,arrows=-,dash=2pt 2pt}
psLine(R)(R|0,0)
psLine(R)(0,0|R)
end{pspicture}}
end{document}
Is there another simpler, high level (as opposed to the low level with PSTricks core macro) workaround that I can digest and adopt for my future projects?
– kiss my armpit
Sep 5 '12 at 13:01
add a comment |
With pstricks.tex
from http://archiv.dante.de/~herbert/texnik/tex/generic/pstricks/ psLine
can have only one or two pairs of coordinates. Will later be on CTAN.
documentclass[pstricks,border=12pt]{standalone}
usepackage{pst-node,multido}
begin{document}
multido{i=0+30}{12}{%
begin{pspicture}(-2,-2)(2,2)
pscircle{1}
pnode(1;i){R}
psset{arrows=->}
psLine(R)
psLine[linecolor=blue](R|0,0)
psLine[linecolor=red](0,0|R)
psset{linecolor=gray,linestyle=dashed,linewidth=0.5pslinewidth,arrows=-,dash=2pt 2pt}
psLine(R)(R|0,0)
psLine(R)(0,0|R)
end{pspicture}}
end{document}
Is there another simpler, high level (as opposed to the low level with PSTricks core macro) workaround that I can digest and adopt for my future projects?
– kiss my armpit
Sep 5 '12 at 13:01
add a comment |
With pstricks.tex
from http://archiv.dante.de/~herbert/texnik/tex/generic/pstricks/ psLine
can have only one or two pairs of coordinates. Will later be on CTAN.
documentclass[pstricks,border=12pt]{standalone}
usepackage{pst-node,multido}
begin{document}
multido{i=0+30}{12}{%
begin{pspicture}(-2,-2)(2,2)
pscircle{1}
pnode(1;i){R}
psset{arrows=->}
psLine(R)
psLine[linecolor=blue](R|0,0)
psLine[linecolor=red](0,0|R)
psset{linecolor=gray,linestyle=dashed,linewidth=0.5pslinewidth,arrows=-,dash=2pt 2pt}
psLine(R)(R|0,0)
psLine(R)(0,0|R)
end{pspicture}}
end{document}
With pstricks.tex
from http://archiv.dante.de/~herbert/texnik/tex/generic/pstricks/ psLine
can have only one or two pairs of coordinates. Will later be on CTAN.
documentclass[pstricks,border=12pt]{standalone}
usepackage{pst-node,multido}
begin{document}
multido{i=0+30}{12}{%
begin{pspicture}(-2,-2)(2,2)
pscircle{1}
pnode(1;i){R}
psset{arrows=->}
psLine(R)
psLine[linecolor=blue](R|0,0)
psLine[linecolor=red](0,0|R)
psset{linecolor=gray,linestyle=dashed,linewidth=0.5pslinewidth,arrows=-,dash=2pt 2pt}
psLine(R)(R|0,0)
psLine(R)(0,0|R)
end{pspicture}}
end{document}
edited 3 hours ago
answered Sep 5 '12 at 12:35
HerbertHerbert
270k24408717
270k24408717
Is there another simpler, high level (as opposed to the low level with PSTricks core macro) workaround that I can digest and adopt for my future projects?
– kiss my armpit
Sep 5 '12 at 13:01
add a comment |
Is there another simpler, high level (as opposed to the low level with PSTricks core macro) workaround that I can digest and adopt for my future projects?
– kiss my armpit
Sep 5 '12 at 13:01
Is there another simpler, high level (as opposed to the low level with PSTricks core macro) workaround that I can digest and adopt for my future projects?
– kiss my armpit
Sep 5 '12 at 13:01
Is there another simpler, high level (as opposed to the low level with PSTricks core macro) workaround that I can digest and adopt for my future projects?
– kiss my armpit
Sep 5 '12 at 13:01
add a comment |
In TikZ, you can avoid drawing arrow heads if the last segment of a path has a length of zero by patching the internal pgf@check@for@arrows
macro:
makeatletter
defpgf@check@for@arrows{%
pgf@drawarrowsfalse%
ifxpgf@startarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifxpgf@endarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifdimpgf@shorten@end@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifdimpgf@shorten@start@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifpgf@drawarrows%
pgfsyssoftpath@getcurrentpathpgf@arrowpath%
ifxpgf@arrowpathpgfutil@empty%
pgf@drawarrowsfalse%
else%
pgfprocesscheckclosed{pgf@arrowpath}{pgf@drawarrowsfalse}%
%%% New stuff starts here
% Extract first, second, second last and last points
pgfprocesspathextractpoints{pgf@arrowpath}%
% If the second last and last points are identical ...
ifxpgfpointsecondlastonpathpgfpointlastonpath%
% ... disable the arrow head
pgf@drawarrowsfalse%
fi%
%%% New stuff ends here
fi%
fi%
}
makeatother
documentclass[tikz,border=0pt]{standalone}
usepackage{tikz}
makeatletter
defpgf@check@for@arrows{%
pgf@drawarrowsfalse%
ifxpgf@startarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifxpgf@endarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifdimpgf@shorten@end@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifdimpgf@shorten@start@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifpgf@drawarrows%
pgfsyssoftpath@getcurrentpathpgf@arrowpath%
ifxpgf@arrowpathpgfutil@empty%
pgf@drawarrowsfalse%
else%
pgfprocesscheckclosed{pgf@arrowpath}{pgf@drawarrowsfalse}%
pgfprocesspathextractpoints{pgf@arrowpath}%
ifxpgfpointsecondlastonpathpgfpointlastonpath%
pgf@drawarrowsfalse%
fi%
fi%
fi%
}
makeatother
begin{document}
foreach angle in {0,5,...,355}{%
begin{tikzpicture}[
scale=1.5,
arrow/.style={
-stealth, thick, line cap=round
}
]
fill [white] (-1.02,-1.02) rectangle (1.02, 1.02);
draw [gray, densely dashed] (0:{cos(angle)}) |- (90:{sin(angle)});
draw (0,0) circle [radius=1];
draw [blue, arrow] (0,0) -- (0:{cos(angle)});
draw [red, arrow] (0,0) -- (90:{sin(angle)});
draw [black, arrow] (0,0) -- (angle:1);
end{tikzpicture}%
}
end{document}
add a comment |
In TikZ, you can avoid drawing arrow heads if the last segment of a path has a length of zero by patching the internal pgf@check@for@arrows
macro:
makeatletter
defpgf@check@for@arrows{%
pgf@drawarrowsfalse%
ifxpgf@startarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifxpgf@endarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifdimpgf@shorten@end@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifdimpgf@shorten@start@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifpgf@drawarrows%
pgfsyssoftpath@getcurrentpathpgf@arrowpath%
ifxpgf@arrowpathpgfutil@empty%
pgf@drawarrowsfalse%
else%
pgfprocesscheckclosed{pgf@arrowpath}{pgf@drawarrowsfalse}%
%%% New stuff starts here
% Extract first, second, second last and last points
pgfprocesspathextractpoints{pgf@arrowpath}%
% If the second last and last points are identical ...
ifxpgfpointsecondlastonpathpgfpointlastonpath%
% ... disable the arrow head
pgf@drawarrowsfalse%
fi%
%%% New stuff ends here
fi%
fi%
}
makeatother
documentclass[tikz,border=0pt]{standalone}
usepackage{tikz}
makeatletter
defpgf@check@for@arrows{%
pgf@drawarrowsfalse%
ifxpgf@startarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifxpgf@endarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifdimpgf@shorten@end@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifdimpgf@shorten@start@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifpgf@drawarrows%
pgfsyssoftpath@getcurrentpathpgf@arrowpath%
ifxpgf@arrowpathpgfutil@empty%
pgf@drawarrowsfalse%
else%
pgfprocesscheckclosed{pgf@arrowpath}{pgf@drawarrowsfalse}%
pgfprocesspathextractpoints{pgf@arrowpath}%
ifxpgfpointsecondlastonpathpgfpointlastonpath%
pgf@drawarrowsfalse%
fi%
fi%
fi%
}
makeatother
begin{document}
foreach angle in {0,5,...,355}{%
begin{tikzpicture}[
scale=1.5,
arrow/.style={
-stealth, thick, line cap=round
}
]
fill [white] (-1.02,-1.02) rectangle (1.02, 1.02);
draw [gray, densely dashed] (0:{cos(angle)}) |- (90:{sin(angle)});
draw (0,0) circle [radius=1];
draw [blue, arrow] (0,0) -- (0:{cos(angle)});
draw [red, arrow] (0,0) -- (90:{sin(angle)});
draw [black, arrow] (0,0) -- (angle:1);
end{tikzpicture}%
}
end{document}
add a comment |
In TikZ, you can avoid drawing arrow heads if the last segment of a path has a length of zero by patching the internal pgf@check@for@arrows
macro:
makeatletter
defpgf@check@for@arrows{%
pgf@drawarrowsfalse%
ifxpgf@startarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifxpgf@endarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifdimpgf@shorten@end@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifdimpgf@shorten@start@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifpgf@drawarrows%
pgfsyssoftpath@getcurrentpathpgf@arrowpath%
ifxpgf@arrowpathpgfutil@empty%
pgf@drawarrowsfalse%
else%
pgfprocesscheckclosed{pgf@arrowpath}{pgf@drawarrowsfalse}%
%%% New stuff starts here
% Extract first, second, second last and last points
pgfprocesspathextractpoints{pgf@arrowpath}%
% If the second last and last points are identical ...
ifxpgfpointsecondlastonpathpgfpointlastonpath%
% ... disable the arrow head
pgf@drawarrowsfalse%
fi%
%%% New stuff ends here
fi%
fi%
}
makeatother
documentclass[tikz,border=0pt]{standalone}
usepackage{tikz}
makeatletter
defpgf@check@for@arrows{%
pgf@drawarrowsfalse%
ifxpgf@startarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifxpgf@endarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifdimpgf@shorten@end@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifdimpgf@shorten@start@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifpgf@drawarrows%
pgfsyssoftpath@getcurrentpathpgf@arrowpath%
ifxpgf@arrowpathpgfutil@empty%
pgf@drawarrowsfalse%
else%
pgfprocesscheckclosed{pgf@arrowpath}{pgf@drawarrowsfalse}%
pgfprocesspathextractpoints{pgf@arrowpath}%
ifxpgfpointsecondlastonpathpgfpointlastonpath%
pgf@drawarrowsfalse%
fi%
fi%
fi%
}
makeatother
begin{document}
foreach angle in {0,5,...,355}{%
begin{tikzpicture}[
scale=1.5,
arrow/.style={
-stealth, thick, line cap=round
}
]
fill [white] (-1.02,-1.02) rectangle (1.02, 1.02);
draw [gray, densely dashed] (0:{cos(angle)}) |- (90:{sin(angle)});
draw (0,0) circle [radius=1];
draw [blue, arrow] (0,0) -- (0:{cos(angle)});
draw [red, arrow] (0,0) -- (90:{sin(angle)});
draw [black, arrow] (0,0) -- (angle:1);
end{tikzpicture}%
}
end{document}
In TikZ, you can avoid drawing arrow heads if the last segment of a path has a length of zero by patching the internal pgf@check@for@arrows
macro:
makeatletter
defpgf@check@for@arrows{%
pgf@drawarrowsfalse%
ifxpgf@startarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifxpgf@endarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifdimpgf@shorten@end@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifdimpgf@shorten@start@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifpgf@drawarrows%
pgfsyssoftpath@getcurrentpathpgf@arrowpath%
ifxpgf@arrowpathpgfutil@empty%
pgf@drawarrowsfalse%
else%
pgfprocesscheckclosed{pgf@arrowpath}{pgf@drawarrowsfalse}%
%%% New stuff starts here
% Extract first, second, second last and last points
pgfprocesspathextractpoints{pgf@arrowpath}%
% If the second last and last points are identical ...
ifxpgfpointsecondlastonpathpgfpointlastonpath%
% ... disable the arrow head
pgf@drawarrowsfalse%
fi%
%%% New stuff ends here
fi%
fi%
}
makeatother
documentclass[tikz,border=0pt]{standalone}
usepackage{tikz}
makeatletter
defpgf@check@for@arrows{%
pgf@drawarrowsfalse%
ifxpgf@startarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifxpgf@endarrowpgfutil@emptyelsepgf@drawarrowstruefi%
ifdimpgf@shorten@end@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifdimpgf@shorten@start@additional=0ptrelaxelsepgf@drawarrowstruefi%
ifpgf@drawarrows%
pgfsyssoftpath@getcurrentpathpgf@arrowpath%
ifxpgf@arrowpathpgfutil@empty%
pgf@drawarrowsfalse%
else%
pgfprocesscheckclosed{pgf@arrowpath}{pgf@drawarrowsfalse}%
pgfprocesspathextractpoints{pgf@arrowpath}%
ifxpgfpointsecondlastonpathpgfpointlastonpath%
pgf@drawarrowsfalse%
fi%
fi%
fi%
}
makeatother
begin{document}
foreach angle in {0,5,...,355}{%
begin{tikzpicture}[
scale=1.5,
arrow/.style={
-stealth, thick, line cap=round
}
]
fill [white] (-1.02,-1.02) rectangle (1.02, 1.02);
draw [gray, densely dashed] (0:{cos(angle)}) |- (90:{sin(angle)});
draw (0,0) circle [radius=1];
draw [blue, arrow] (0,0) -- (0:{cos(angle)});
draw [red, arrow] (0,0) -- (90:{sin(angle)});
draw [black, arrow] (0,0) -- (angle:1);
end{tikzpicture}%
}
end{document}
edited Oct 6 '13 at 10:53
answered Oct 6 '13 at 10:46
JakeJake
193k24647761
193k24647761
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f70186%2fdoes-a-zero-length-line-with-an-arrow-make-sense-is-it-a-bug%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
1
Add an epsilon perturbation so that direction is properly defined.
– Aditya
Sep 5 '12 at 4:33
why should this be a bug? If the user defines an arrow then it is drawn.
– Herbert
Sep 5 '12 at 11:54
@Herbert: Because it does not make sense. It will be better if the PSTricks core automatically does nothing for zero-length lines.
– kiss my armpit
Sep 5 '12 at 11:58
that has the user to be decide if it makes sense or not ...
– Herbert
Sep 5 '12 at 12:13
@Herbert: If the line length with an arrow is measured from the tip of the arrow to the tail of the line then a zero-length line should be invisible. :-)
– kiss my armpit
Sep 5 '12 at 12:15