“Straight” (tangent) connections to both ends of Bézier curve











up vote
2
down vote

favorite












I would like to draw a relatively thick Bézier curve that goes all the way to the edge of a rectangle. In the MWE below, the eventual clipping boundary is represented by the drawn rectangle.



I like the shape of the curve from (0,10) to (20,30), but I want that small remaining triangle to be filled in as well. I found the ([turn]...) syntax which works well for the end of the curve, but can't work for the start of the curve.



My kludgy solution is to draw the curve twice, once starting from the top and once starting from the bottom, but seems like there must be a better way.



In actual use, these curves aren't simply from points like in the MWE but are parameterized relative to other dimensions of the image, which is why I don't want to manually calculate the tangent line and hardcode the numbers in.



EDIT: I realize I may be asking for a particular solution to the problem instead of just the easiest. If there is a way to "straight" extend a path that doesn't involve ([turn]...) or tangents, I'm open to that solution as well. (Although the original question is interesting to me even so.)



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}
draw (0, 0) rectangle (30, 30);

draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0, 10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30);
draw[green, opacity=0.25, line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0, 10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) -- ([turn]0:2);
draw[blue, opacity=0.25, line width=1.333cm, line cap=rect] (20, 30) .. controls ($(0, 10)!0.666!(20, 30) + (-1, 1)$) and ($(0, 10)!0.333!(20, 30) + (-1, 1)$) .. (0, 10) -- ([turn]0:2);

draw[red] (0, 10) -- ($(0, 10)!0.333!(20, 30) +(-1, 1)$) -- ($(0, 10)!0.666!(20, 30) + (-1, 1)$) -- (20, 30);
end{tikzpicture}
end{document}


output of the MWE



EDIT 2: added arrows for clarity (sorry, I used Preview.app to add them, not TeX :P )



I would like the black line to extend far enough so it gets clipped "flat" by the rectangle and doesn't leave that small internal triangle.



MWE annotated with arrows to show the problem area










share|improve this question
























  • A solution is possible using the approach in this post: tex.stackexchange.com/q/25928/19170. However, the bug found in this question appears to happen with [tangent=0, tangent=1], necessitating [tangent=0, tangent=0.99999]. As mentioned in the second link, adding one more "9" brings back the bug.
    – Scott Colby
    1 hour ago

















up vote
2
down vote

favorite












I would like to draw a relatively thick Bézier curve that goes all the way to the edge of a rectangle. In the MWE below, the eventual clipping boundary is represented by the drawn rectangle.



I like the shape of the curve from (0,10) to (20,30), but I want that small remaining triangle to be filled in as well. I found the ([turn]...) syntax which works well for the end of the curve, but can't work for the start of the curve.



My kludgy solution is to draw the curve twice, once starting from the top and once starting from the bottom, but seems like there must be a better way.



In actual use, these curves aren't simply from points like in the MWE but are parameterized relative to other dimensions of the image, which is why I don't want to manually calculate the tangent line and hardcode the numbers in.



EDIT: I realize I may be asking for a particular solution to the problem instead of just the easiest. If there is a way to "straight" extend a path that doesn't involve ([turn]...) or tangents, I'm open to that solution as well. (Although the original question is interesting to me even so.)



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}
draw (0, 0) rectangle (30, 30);

draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0, 10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30);
draw[green, opacity=0.25, line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0, 10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) -- ([turn]0:2);
draw[blue, opacity=0.25, line width=1.333cm, line cap=rect] (20, 30) .. controls ($(0, 10)!0.666!(20, 30) + (-1, 1)$) and ($(0, 10)!0.333!(20, 30) + (-1, 1)$) .. (0, 10) -- ([turn]0:2);

draw[red] (0, 10) -- ($(0, 10)!0.333!(20, 30) +(-1, 1)$) -- ($(0, 10)!0.666!(20, 30) + (-1, 1)$) -- (20, 30);
end{tikzpicture}
end{document}


output of the MWE



EDIT 2: added arrows for clarity (sorry, I used Preview.app to add them, not TeX :P )



I would like the black line to extend far enough so it gets clipped "flat" by the rectangle and doesn't leave that small internal triangle.



MWE annotated with arrows to show the problem area










share|improve this question
























  • A solution is possible using the approach in this post: tex.stackexchange.com/q/25928/19170. However, the bug found in this question appears to happen with [tangent=0, tangent=1], necessitating [tangent=0, tangent=0.99999]. As mentioned in the second link, adding one more "9" brings back the bug.
    – Scott Colby
    1 hour ago















up vote
2
down vote

favorite









up vote
2
down vote

favorite











I would like to draw a relatively thick Bézier curve that goes all the way to the edge of a rectangle. In the MWE below, the eventual clipping boundary is represented by the drawn rectangle.



I like the shape of the curve from (0,10) to (20,30), but I want that small remaining triangle to be filled in as well. I found the ([turn]...) syntax which works well for the end of the curve, but can't work for the start of the curve.



My kludgy solution is to draw the curve twice, once starting from the top and once starting from the bottom, but seems like there must be a better way.



In actual use, these curves aren't simply from points like in the MWE but are parameterized relative to other dimensions of the image, which is why I don't want to manually calculate the tangent line and hardcode the numbers in.



EDIT: I realize I may be asking for a particular solution to the problem instead of just the easiest. If there is a way to "straight" extend a path that doesn't involve ([turn]...) or tangents, I'm open to that solution as well. (Although the original question is interesting to me even so.)



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}
draw (0, 0) rectangle (30, 30);

draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0, 10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30);
draw[green, opacity=0.25, line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0, 10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) -- ([turn]0:2);
draw[blue, opacity=0.25, line width=1.333cm, line cap=rect] (20, 30) .. controls ($(0, 10)!0.666!(20, 30) + (-1, 1)$) and ($(0, 10)!0.333!(20, 30) + (-1, 1)$) .. (0, 10) -- ([turn]0:2);

draw[red] (0, 10) -- ($(0, 10)!0.333!(20, 30) +(-1, 1)$) -- ($(0, 10)!0.666!(20, 30) + (-1, 1)$) -- (20, 30);
end{tikzpicture}
end{document}


output of the MWE



EDIT 2: added arrows for clarity (sorry, I used Preview.app to add them, not TeX :P )



I would like the black line to extend far enough so it gets clipped "flat" by the rectangle and doesn't leave that small internal triangle.



MWE annotated with arrows to show the problem area










share|improve this question















I would like to draw a relatively thick Bézier curve that goes all the way to the edge of a rectangle. In the MWE below, the eventual clipping boundary is represented by the drawn rectangle.



I like the shape of the curve from (0,10) to (20,30), but I want that small remaining triangle to be filled in as well. I found the ([turn]...) syntax which works well for the end of the curve, but can't work for the start of the curve.



My kludgy solution is to draw the curve twice, once starting from the top and once starting from the bottom, but seems like there must be a better way.



In actual use, these curves aren't simply from points like in the MWE but are parameterized relative to other dimensions of the image, which is why I don't want to manually calculate the tangent line and hardcode the numbers in.



EDIT: I realize I may be asking for a particular solution to the problem instead of just the easiest. If there is a way to "straight" extend a path that doesn't involve ([turn]...) or tangents, I'm open to that solution as well. (Although the original question is interesting to me even so.)



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}
draw (0, 0) rectangle (30, 30);

draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0, 10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30);
draw[green, opacity=0.25, line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0, 10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) -- ([turn]0:2);
draw[blue, opacity=0.25, line width=1.333cm, line cap=rect] (20, 30) .. controls ($(0, 10)!0.666!(20, 30) + (-1, 1)$) and ($(0, 10)!0.333!(20, 30) + (-1, 1)$) .. (0, 10) -- ([turn]0:2);

draw[red] (0, 10) -- ($(0, 10)!0.333!(20, 30) +(-1, 1)$) -- ($(0, 10)!0.666!(20, 30) + (-1, 1)$) -- (20, 30);
end{tikzpicture}
end{document}


output of the MWE



EDIT 2: added arrows for clarity (sorry, I used Preview.app to add them, not TeX :P )



I would like the black line to extend far enough so it gets clipped "flat" by the rectangle and doesn't leave that small internal triangle.



MWE annotated with arrows to show the problem area







tikz-pgf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago

























asked 1 hour ago









Scott Colby

1847




1847












  • A solution is possible using the approach in this post: tex.stackexchange.com/q/25928/19170. However, the bug found in this question appears to happen with [tangent=0, tangent=1], necessitating [tangent=0, tangent=0.99999]. As mentioned in the second link, adding one more "9" brings back the bug.
    – Scott Colby
    1 hour ago




















  • A solution is possible using the approach in this post: tex.stackexchange.com/q/25928/19170. However, the bug found in this question appears to happen with [tangent=0, tangent=1], necessitating [tangent=0, tangent=0.99999]. As mentioned in the second link, adding one more "9" brings back the bug.
    – Scott Colby
    1 hour ago


















A solution is possible using the approach in this post: tex.stackexchange.com/q/25928/19170. However, the bug found in this question appears to happen with [tangent=0, tangent=1], necessitating [tangent=0, tangent=0.99999]. As mentioned in the second link, adding one more "9" brings back the bug.
– Scott Colby
1 hour ago






A solution is possible using the approach in this post: tex.stackexchange.com/q/25928/19170. However, the bug found in this question appears to happen with [tangent=0, tangent=1], necessitating [tangent=0, tangent=0.99999]. As mentioned in the second link, adding one more "9" brings back the bug.
– Scott Colby
1 hour ago












1 Answer
1






active

oldest

votes

















up vote
0
down vote













I see. Better now? This adds some smooth cotinuation at both ends.



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) coordinate[pos=-0.1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1.1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4);
end{tikzpicture}
end{document}


enter image description here



You could make this a style, of course.



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}[continuation/.style={insert path={coordinate[pos=-#1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1+#1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4)}}]
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) [continuation=0.1];
end{tikzpicture}
end{document}


and also produce the mandatory animation



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
tikzset{continuation/.style={insert path={coordinate[pos=-#1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1+#1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4)}}}
foreach X in {0.01,0.02,...,0.25}
{begin{tikzpicture}
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) [continuation=X];
end{tikzpicture}}
end{document}


enter image description here






share|improve this answer























  • The problem isn't with the the extra green and blue, but the tiny triangle of white that would be left over inside the rectangle if the green and blue paths weren't there.
    – Scott Colby
    1 hour ago










  • @ScottColby Still not sure if I understand the question but does that come closer to what you want?
    – marmot
    1 hour ago










  • Yes, it's so close, but if you draw the auxiliary lines with reduced opacity and a different color, you'll see that they're not quite tangent to the Bézier. Not that anyone would probably notice/care at any reasonable print size, so this is acceptable if we can't find another way, but it would be nice to get things lined up perfectly.
    – Scott Colby
    1 hour ago










  • @ScottColby I am aware of the tangent solution but I am also aware of this issue, so I am afraid that the tangent solution may be more shaky than what I have. (The true question is which of these methods yield the "true" tangent. I believe that the above is sufficiently close to the true solution in the sense that it is almost indistinguishable from it.)
    – marmot
    1 hour ago










  • That's a much better investigation of the problem than the question I linked in my comment above! I'll do some reading and come back here.
    – Scott Colby
    44 mins ago











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',
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
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f462277%2fstraight-tangent-connections-to-both-ends-of-b%25c3%25a9zier-curve%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













I see. Better now? This adds some smooth cotinuation at both ends.



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) coordinate[pos=-0.1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1.1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4);
end{tikzpicture}
end{document}


enter image description here



You could make this a style, of course.



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}[continuation/.style={insert path={coordinate[pos=-#1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1+#1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4)}}]
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) [continuation=0.1];
end{tikzpicture}
end{document}


and also produce the mandatory animation



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
tikzset{continuation/.style={insert path={coordinate[pos=-#1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1+#1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4)}}}
foreach X in {0.01,0.02,...,0.25}
{begin{tikzpicture}
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) [continuation=X];
end{tikzpicture}}
end{document}


enter image description here






share|improve this answer























  • The problem isn't with the the extra green and blue, but the tiny triangle of white that would be left over inside the rectangle if the green and blue paths weren't there.
    – Scott Colby
    1 hour ago










  • @ScottColby Still not sure if I understand the question but does that come closer to what you want?
    – marmot
    1 hour ago










  • Yes, it's so close, but if you draw the auxiliary lines with reduced opacity and a different color, you'll see that they're not quite tangent to the Bézier. Not that anyone would probably notice/care at any reasonable print size, so this is acceptable if we can't find another way, but it would be nice to get things lined up perfectly.
    – Scott Colby
    1 hour ago










  • @ScottColby I am aware of the tangent solution but I am also aware of this issue, so I am afraid that the tangent solution may be more shaky than what I have. (The true question is which of these methods yield the "true" tangent. I believe that the above is sufficiently close to the true solution in the sense that it is almost indistinguishable from it.)
    – marmot
    1 hour ago










  • That's a much better investigation of the problem than the question I linked in my comment above! I'll do some reading and come back here.
    – Scott Colby
    44 mins ago















up vote
0
down vote













I see. Better now? This adds some smooth cotinuation at both ends.



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) coordinate[pos=-0.1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1.1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4);
end{tikzpicture}
end{document}


enter image description here



You could make this a style, of course.



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}[continuation/.style={insert path={coordinate[pos=-#1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1+#1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4)}}]
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) [continuation=0.1];
end{tikzpicture}
end{document}


and also produce the mandatory animation



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
tikzset{continuation/.style={insert path={coordinate[pos=-#1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1+#1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4)}}}
foreach X in {0.01,0.02,...,0.25}
{begin{tikzpicture}
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) [continuation=X];
end{tikzpicture}}
end{document}


enter image description here






share|improve this answer























  • The problem isn't with the the extra green and blue, but the tiny triangle of white that would be left over inside the rectangle if the green and blue paths weren't there.
    – Scott Colby
    1 hour ago










  • @ScottColby Still not sure if I understand the question but does that come closer to what you want?
    – marmot
    1 hour ago










  • Yes, it's so close, but if you draw the auxiliary lines with reduced opacity and a different color, you'll see that they're not quite tangent to the Bézier. Not that anyone would probably notice/care at any reasonable print size, so this is acceptable if we can't find another way, but it would be nice to get things lined up perfectly.
    – Scott Colby
    1 hour ago










  • @ScottColby I am aware of the tangent solution but I am also aware of this issue, so I am afraid that the tangent solution may be more shaky than what I have. (The true question is which of these methods yield the "true" tangent. I believe that the above is sufficiently close to the true solution in the sense that it is almost indistinguishable from it.)
    – marmot
    1 hour ago










  • That's a much better investigation of the problem than the question I linked in my comment above! I'll do some reading and come back here.
    – Scott Colby
    44 mins ago













up vote
0
down vote










up vote
0
down vote









I see. Better now? This adds some smooth cotinuation at both ends.



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) coordinate[pos=-0.1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1.1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4);
end{tikzpicture}
end{document}


enter image description here



You could make this a style, of course.



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}[continuation/.style={insert path={coordinate[pos=-#1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1+#1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4)}}]
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) [continuation=0.1];
end{tikzpicture}
end{document}


and also produce the mandatory animation



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
tikzset{continuation/.style={insert path={coordinate[pos=-#1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1+#1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4)}}}
foreach X in {0.01,0.02,...,0.25}
{begin{tikzpicture}
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) [continuation=X];
end{tikzpicture}}
end{document}


enter image description here






share|improve this answer














I see. Better now? This adds some smooth cotinuation at both ends.



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) coordinate[pos=-0.1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1.1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4);
end{tikzpicture}
end{document}


enter image description here



You could make this a style, of course.



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}[continuation/.style={insert path={coordinate[pos=-#1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1+#1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4)}}]
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) [continuation=0.1];
end{tikzpicture}
end{document}


and also produce the mandatory animation



documentclass[tikz, margin=1cm]{standalone}
usetikzlibrary{calc}

begin{document}
tikzset{continuation/.style={insert path={coordinate[pos=-#1] (aux1) coordinate[pos=0] (aux2)
coordinate[pos=1+#1] (aux3) coordinate[pos=1] (aux4)
(aux1) -- (aux2) (aux3) -- (aux4)}}}
foreach X in {0.01,0.02,...,0.25}
{begin{tikzpicture}
draw (0, 0) rectangle (30, 30);
draw[line width=1.333cm, line cap=rect] (0, 10) .. controls ($(0, 10)!0.333!(20, 30) + (-1, 1)$) and ($(0,
10)!0.666!(20, 30) + (-1, 1)$) .. (20, 30) [continuation=X];
end{tikzpicture}}
end{document}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited 1 hour ago

























answered 1 hour ago









marmot

78.8k487166




78.8k487166












  • The problem isn't with the the extra green and blue, but the tiny triangle of white that would be left over inside the rectangle if the green and blue paths weren't there.
    – Scott Colby
    1 hour ago










  • @ScottColby Still not sure if I understand the question but does that come closer to what you want?
    – marmot
    1 hour ago










  • Yes, it's so close, but if you draw the auxiliary lines with reduced opacity and a different color, you'll see that they're not quite tangent to the Bézier. Not that anyone would probably notice/care at any reasonable print size, so this is acceptable if we can't find another way, but it would be nice to get things lined up perfectly.
    – Scott Colby
    1 hour ago










  • @ScottColby I am aware of the tangent solution but I am also aware of this issue, so I am afraid that the tangent solution may be more shaky than what I have. (The true question is which of these methods yield the "true" tangent. I believe that the above is sufficiently close to the true solution in the sense that it is almost indistinguishable from it.)
    – marmot
    1 hour ago










  • That's a much better investigation of the problem than the question I linked in my comment above! I'll do some reading and come back here.
    – Scott Colby
    44 mins ago


















  • The problem isn't with the the extra green and blue, but the tiny triangle of white that would be left over inside the rectangle if the green and blue paths weren't there.
    – Scott Colby
    1 hour ago










  • @ScottColby Still not sure if I understand the question but does that come closer to what you want?
    – marmot
    1 hour ago










  • Yes, it's so close, but if you draw the auxiliary lines with reduced opacity and a different color, you'll see that they're not quite tangent to the Bézier. Not that anyone would probably notice/care at any reasonable print size, so this is acceptable if we can't find another way, but it would be nice to get things lined up perfectly.
    – Scott Colby
    1 hour ago










  • @ScottColby I am aware of the tangent solution but I am also aware of this issue, so I am afraid that the tangent solution may be more shaky than what I have. (The true question is which of these methods yield the "true" tangent. I believe that the above is sufficiently close to the true solution in the sense that it is almost indistinguishable from it.)
    – marmot
    1 hour ago










  • That's a much better investigation of the problem than the question I linked in my comment above! I'll do some reading and come back here.
    – Scott Colby
    44 mins ago
















The problem isn't with the the extra green and blue, but the tiny triangle of white that would be left over inside the rectangle if the green and blue paths weren't there.
– Scott Colby
1 hour ago




The problem isn't with the the extra green and blue, but the tiny triangle of white that would be left over inside the rectangle if the green and blue paths weren't there.
– Scott Colby
1 hour ago












@ScottColby Still not sure if I understand the question but does that come closer to what you want?
– marmot
1 hour ago




@ScottColby Still not sure if I understand the question but does that come closer to what you want?
– marmot
1 hour ago












Yes, it's so close, but if you draw the auxiliary lines with reduced opacity and a different color, you'll see that they're not quite tangent to the Bézier. Not that anyone would probably notice/care at any reasonable print size, so this is acceptable if we can't find another way, but it would be nice to get things lined up perfectly.
– Scott Colby
1 hour ago




Yes, it's so close, but if you draw the auxiliary lines with reduced opacity and a different color, you'll see that they're not quite tangent to the Bézier. Not that anyone would probably notice/care at any reasonable print size, so this is acceptable if we can't find another way, but it would be nice to get things lined up perfectly.
– Scott Colby
1 hour ago












@ScottColby I am aware of the tangent solution but I am also aware of this issue, so I am afraid that the tangent solution may be more shaky than what I have. (The true question is which of these methods yield the "true" tangent. I believe that the above is sufficiently close to the true solution in the sense that it is almost indistinguishable from it.)
– marmot
1 hour ago




@ScottColby I am aware of the tangent solution but I am also aware of this issue, so I am afraid that the tangent solution may be more shaky than what I have. (The true question is which of these methods yield the "true" tangent. I believe that the above is sufficiently close to the true solution in the sense that it is almost indistinguishable from it.)
– marmot
1 hour ago












That's a much better investigation of the problem than the question I linked in my comment above! I'll do some reading and come back here.
– Scott Colby
44 mins ago




That's a much better investigation of the problem than the question I linked in my comment above! I'll do some reading and come back here.
– Scott Colby
44 mins ago


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f462277%2fstraight-tangent-connections-to-both-ends-of-b%25c3%25a9zier-curve%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Lallio

Futebolista

Jornalista