TikZ specifying barycentric coordinates using just lists of numbers
Here's what I currently have to type:
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
draw [thick,green, fill=green,opacity=0.5]
(barycentric cs:a=1,b=0,c=0) --
(barycentric cs:a=1,b=0,c=1) --
(barycentric cs:a=1,b=1,c=0) -- cycle;
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
This is a little tedious. Since I'll want to draw lots of shapes using the same a,b,c-based barycentric coordinates. Is there a way to pass an option to scope
for example that would allow me to have (1,0,1)
evaluate as (barycentric cs:a=1,b=0,c=1)
?
tikz-pgf diagrams coordinates
add a comment |
Here's what I currently have to type:
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
draw [thick,green, fill=green,opacity=0.5]
(barycentric cs:a=1,b=0,c=0) --
(barycentric cs:a=1,b=0,c=1) --
(barycentric cs:a=1,b=1,c=0) -- cycle;
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
This is a little tedious. Since I'll want to draw lots of shapes using the same a,b,c-based barycentric coordinates. Is there a way to pass an option to scope
for example that would allow me to have (1,0,1)
evaluate as (barycentric cs:a=1,b=0,c=1)
?
tikz-pgf diagrams coordinates
add a comment |
Here's what I currently have to type:
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
draw [thick,green, fill=green,opacity=0.5]
(barycentric cs:a=1,b=0,c=0) --
(barycentric cs:a=1,b=0,c=1) --
(barycentric cs:a=1,b=1,c=0) -- cycle;
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
This is a little tedious. Since I'll want to draw lots of shapes using the same a,b,c-based barycentric coordinates. Is there a way to pass an option to scope
for example that would allow me to have (1,0,1)
evaluate as (barycentric cs:a=1,b=0,c=1)
?
tikz-pgf diagrams coordinates
Here's what I currently have to type:
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
draw [thick,green, fill=green,opacity=0.5]
(barycentric cs:a=1,b=0,c=0) --
(barycentric cs:a=1,b=0,c=1) --
(barycentric cs:a=1,b=1,c=0) -- cycle;
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
This is a little tedious. Since I'll want to draw lots of shapes using the same a,b,c-based barycentric coordinates. Is there a way to pass an option to scope
for example that would allow me to have (1,0,1)
evaluate as (barycentric cs:a=1,b=0,c=1)
?
tikz-pgf diagrams coordinates
tikz-pgf diagrams coordinates
asked yesterday
Seamus
45k35216332
45k35216332
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
You can define
newcommand{foo}[3]{(barycentric cs:a=#1,b=#2,c=#3)}
and then use it as
draw [thick,green, fill=green,opacity=0.5]
foo{1}{0}{0} --
foo{1}{0}{1} --
foo{1}{1}{0} -- cycle;
or combine with another command with 9 parameters
newcommand{faa}[9]{
draw [thick,green, fill=green,opacity=0.5]
foo{#1}{#2}{#3} --
foo{#4}{#5}{#6} --
foo{#7}{#8}{#9} -- cycle;
}
and use as
faa{1}{0}{0}{1}{0}{1}{1}{1}{1}
MWE
documentclass{standalone}
usepackage{tikz}
newcommand{foo}[3]{(barycentric cs:a=#1,b=#2,c=#3)}
newcommand{faa}[9]{
draw [thick,green, fill=green,opacity=0.5]
foo{#1}{#2}{#3} --
foo{#4}{#5}{#6} --
foo{#7}{#8}{#9} -- cycle;
}
begin{document}
begin{tikzpicture}
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
draw [thick,green, fill=green,opacity=0.5]
foo{1}{0}{0} --
foo{1}{0}{1} --
foo{1}{1}{0} -- cycle;
faa{1}{0}{0}{1}{0}{1}{1}{1}{1}
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
1
+1. Suggestion : usedef
in place ofnewcommand
to make more "friendly" interface. For exampledefbc(#1:#2:#3){(barycentric cs:a=#1,b=#2,c=#3)}
can be used after asbc(1:0:0)
.
– Kpym
yesterday
add a comment |
If it is ok for you to use normalized barycentric coordinates, ie (x,y,z)
such that x+y+z=1
, then you can simply set x=(a),y=(b),z=(c)
. So in place of (1,1,0)
you should use (.5,.5,0)
.
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
path
(90:3cm) coordinate (a) node[above] {$a$}
(210:3cm) coordinate (b) node[below left] {$b$}
(-30:3cm) coordinate (c) node[below right] {$c$};
draw [thick,green, fill=green,opacity=0.5]
(barycentric cs:a=1,b=0,c=0) --
(barycentric cs:a=1,b=0,c=1) --
(barycentric cs:a=1,b=1,c=0) -- cycle;
draw [ultra thick] (a) -- (b) -- (c) --cycle;
% set x=(a),y=(b),z=(c) and use normalized barycentric coordinates
draw[ultra thick, red, dashed, x=(a),y=(b),z=(c)]
(1,0,0) -- (.5,0,.5) -- (.5,.5,0) --cycle;
end{tikzpicture}
end{document}
Aha! I was wondering about this. So$x=(a)$
just sets the "x" coordinate inxyz
coordinates to be the vector to(a)
?
– Seamus
yesterday
1
When you setx=(a),y=(b),z=(c)
than(x,y,z)
is a point with coordinatesx.a+y.b+z.c
. That's all.
– Kpym
yesterday
@Kpym I am not angry and would like to see your other, nice answer revived. The only thing I am advocating is to refer to earlier posts by others, if they are related, something that you usually do.
– marmot
yesterday
add a comment |
You can also use insert path
to abbreviate the coordinates.
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}[bcs/.style args={#1|#2|#3}{insert path={--(barycentric
cs:a=#1,b=#2,c=#3)}}]
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
draw [thick,green, fill=green,opacity=0.5] (a)
[bcs={1|0|1},bcs={1|1|0}] -- cycle;
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
Another thing you could do is to locally change the TikZ parser. Then the whole path really boils down to
begin{scope}[bary={a}{b}{c}]
draw [thick,green, fill=green,opacity=0.5]
(1,0,0) -- (1,0,1) -- (1,1,0) -- cycle;
end{scope}
where bary={a}{b}{c}
install the barycentric coordinate system in the scope (we don't want it everywhere) and you really just have to specify the three numbers.
documentclass[tikz,border=3.14mm]{standalone}
makeatletter % https://tex.stackexchange.com/a/365418/121799
tikzset{bary/.code n args={3}{
deftikz@parse@splitxyz##1##2##3,##4,{%
def@next{tikz@scan@one@point##1(barycentric cs:#1=##2,#2=##3,#3=##4)}%
}}}
makeatother
begin{document}
begin{tikzpicture}
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
begin{scope}[bary={a}{b}{c}]
draw [thick,green, fill=green,opacity=0.5]
(1,0,0) -- (1,0,1) -- (1,1,0) -- cycle;
end{scope}
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
Every time I read your answers on TikZ I say to myself I have to study the user guide. I'm afraid the amount of new tools there I never read about!!
– Sigur
yesterday
@Sigur This impression never fades away, regardless how long you read it. ;-)
– marmot
yesterday
I was thinking about this too, but usinginsert path={(barycentric cs:a=#1,b=#2,c=#3)}
do not work at the end of the path. For this reason you added--
in theinsert path
, I suppose. But now you can only draw straight lines :(
– Kpym
yesterday
@Kpym Yes, that's true. This great answer comes with a sort of coordinate system parser, which one may adopt to this situation here. Anyway, I added yet another possibility that changes the TikZ parser locally.
– marmot
yesterday
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%2f468551%2ftikz-specifying-barycentric-coordinates-using-just-lists-of-numbers%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can define
newcommand{foo}[3]{(barycentric cs:a=#1,b=#2,c=#3)}
and then use it as
draw [thick,green, fill=green,opacity=0.5]
foo{1}{0}{0} --
foo{1}{0}{1} --
foo{1}{1}{0} -- cycle;
or combine with another command with 9 parameters
newcommand{faa}[9]{
draw [thick,green, fill=green,opacity=0.5]
foo{#1}{#2}{#3} --
foo{#4}{#5}{#6} --
foo{#7}{#8}{#9} -- cycle;
}
and use as
faa{1}{0}{0}{1}{0}{1}{1}{1}{1}
MWE
documentclass{standalone}
usepackage{tikz}
newcommand{foo}[3]{(barycentric cs:a=#1,b=#2,c=#3)}
newcommand{faa}[9]{
draw [thick,green, fill=green,opacity=0.5]
foo{#1}{#2}{#3} --
foo{#4}{#5}{#6} --
foo{#7}{#8}{#9} -- cycle;
}
begin{document}
begin{tikzpicture}
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
draw [thick,green, fill=green,opacity=0.5]
foo{1}{0}{0} --
foo{1}{0}{1} --
foo{1}{1}{0} -- cycle;
faa{1}{0}{0}{1}{0}{1}{1}{1}{1}
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
1
+1. Suggestion : usedef
in place ofnewcommand
to make more "friendly" interface. For exampledefbc(#1:#2:#3){(barycentric cs:a=#1,b=#2,c=#3)}
can be used after asbc(1:0:0)
.
– Kpym
yesterday
add a comment |
You can define
newcommand{foo}[3]{(barycentric cs:a=#1,b=#2,c=#3)}
and then use it as
draw [thick,green, fill=green,opacity=0.5]
foo{1}{0}{0} --
foo{1}{0}{1} --
foo{1}{1}{0} -- cycle;
or combine with another command with 9 parameters
newcommand{faa}[9]{
draw [thick,green, fill=green,opacity=0.5]
foo{#1}{#2}{#3} --
foo{#4}{#5}{#6} --
foo{#7}{#8}{#9} -- cycle;
}
and use as
faa{1}{0}{0}{1}{0}{1}{1}{1}{1}
MWE
documentclass{standalone}
usepackage{tikz}
newcommand{foo}[3]{(barycentric cs:a=#1,b=#2,c=#3)}
newcommand{faa}[9]{
draw [thick,green, fill=green,opacity=0.5]
foo{#1}{#2}{#3} --
foo{#4}{#5}{#6} --
foo{#7}{#8}{#9} -- cycle;
}
begin{document}
begin{tikzpicture}
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
draw [thick,green, fill=green,opacity=0.5]
foo{1}{0}{0} --
foo{1}{0}{1} --
foo{1}{1}{0} -- cycle;
faa{1}{0}{0}{1}{0}{1}{1}{1}{1}
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
1
+1. Suggestion : usedef
in place ofnewcommand
to make more "friendly" interface. For exampledefbc(#1:#2:#3){(barycentric cs:a=#1,b=#2,c=#3)}
can be used after asbc(1:0:0)
.
– Kpym
yesterday
add a comment |
You can define
newcommand{foo}[3]{(barycentric cs:a=#1,b=#2,c=#3)}
and then use it as
draw [thick,green, fill=green,opacity=0.5]
foo{1}{0}{0} --
foo{1}{0}{1} --
foo{1}{1}{0} -- cycle;
or combine with another command with 9 parameters
newcommand{faa}[9]{
draw [thick,green, fill=green,opacity=0.5]
foo{#1}{#2}{#3} --
foo{#4}{#5}{#6} --
foo{#7}{#8}{#9} -- cycle;
}
and use as
faa{1}{0}{0}{1}{0}{1}{1}{1}{1}
MWE
documentclass{standalone}
usepackage{tikz}
newcommand{foo}[3]{(barycentric cs:a=#1,b=#2,c=#3)}
newcommand{faa}[9]{
draw [thick,green, fill=green,opacity=0.5]
foo{#1}{#2}{#3} --
foo{#4}{#5}{#6} --
foo{#7}{#8}{#9} -- cycle;
}
begin{document}
begin{tikzpicture}
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
draw [thick,green, fill=green,opacity=0.5]
foo{1}{0}{0} --
foo{1}{0}{1} --
foo{1}{1}{0} -- cycle;
faa{1}{0}{0}{1}{0}{1}{1}{1}{1}
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
You can define
newcommand{foo}[3]{(barycentric cs:a=#1,b=#2,c=#3)}
and then use it as
draw [thick,green, fill=green,opacity=0.5]
foo{1}{0}{0} --
foo{1}{0}{1} --
foo{1}{1}{0} -- cycle;
or combine with another command with 9 parameters
newcommand{faa}[9]{
draw [thick,green, fill=green,opacity=0.5]
foo{#1}{#2}{#3} --
foo{#4}{#5}{#6} --
foo{#7}{#8}{#9} -- cycle;
}
and use as
faa{1}{0}{0}{1}{0}{1}{1}{1}{1}
MWE
documentclass{standalone}
usepackage{tikz}
newcommand{foo}[3]{(barycentric cs:a=#1,b=#2,c=#3)}
newcommand{faa}[9]{
draw [thick,green, fill=green,opacity=0.5]
foo{#1}{#2}{#3} --
foo{#4}{#5}{#6} --
foo{#7}{#8}{#9} -- cycle;
}
begin{document}
begin{tikzpicture}
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
draw [thick,green, fill=green,opacity=0.5]
foo{1}{0}{0} --
foo{1}{0}{1} --
foo{1}{1}{0} -- cycle;
faa{1}{0}{0}{1}{0}{1}{1}{1}{1}
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
answered yesterday
Sigur
24.1k355137
24.1k355137
1
+1. Suggestion : usedef
in place ofnewcommand
to make more "friendly" interface. For exampledefbc(#1:#2:#3){(barycentric cs:a=#1,b=#2,c=#3)}
can be used after asbc(1:0:0)
.
– Kpym
yesterday
add a comment |
1
+1. Suggestion : usedef
in place ofnewcommand
to make more "friendly" interface. For exampledefbc(#1:#2:#3){(barycentric cs:a=#1,b=#2,c=#3)}
can be used after asbc(1:0:0)
.
– Kpym
yesterday
1
1
+1. Suggestion : use
def
in place of newcommand
to make more "friendly" interface. For example defbc(#1:#2:#3){(barycentric cs:a=#1,b=#2,c=#3)}
can be used after as bc(1:0:0)
.– Kpym
yesterday
+1. Suggestion : use
def
in place of newcommand
to make more "friendly" interface. For example defbc(#1:#2:#3){(barycentric cs:a=#1,b=#2,c=#3)}
can be used after as bc(1:0:0)
.– Kpym
yesterday
add a comment |
If it is ok for you to use normalized barycentric coordinates, ie (x,y,z)
such that x+y+z=1
, then you can simply set x=(a),y=(b),z=(c)
. So in place of (1,1,0)
you should use (.5,.5,0)
.
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
path
(90:3cm) coordinate (a) node[above] {$a$}
(210:3cm) coordinate (b) node[below left] {$b$}
(-30:3cm) coordinate (c) node[below right] {$c$};
draw [thick,green, fill=green,opacity=0.5]
(barycentric cs:a=1,b=0,c=0) --
(barycentric cs:a=1,b=0,c=1) --
(barycentric cs:a=1,b=1,c=0) -- cycle;
draw [ultra thick] (a) -- (b) -- (c) --cycle;
% set x=(a),y=(b),z=(c) and use normalized barycentric coordinates
draw[ultra thick, red, dashed, x=(a),y=(b),z=(c)]
(1,0,0) -- (.5,0,.5) -- (.5,.5,0) --cycle;
end{tikzpicture}
end{document}
Aha! I was wondering about this. So$x=(a)$
just sets the "x" coordinate inxyz
coordinates to be the vector to(a)
?
– Seamus
yesterday
1
When you setx=(a),y=(b),z=(c)
than(x,y,z)
is a point with coordinatesx.a+y.b+z.c
. That's all.
– Kpym
yesterday
@Kpym I am not angry and would like to see your other, nice answer revived. The only thing I am advocating is to refer to earlier posts by others, if they are related, something that you usually do.
– marmot
yesterday
add a comment |
If it is ok for you to use normalized barycentric coordinates, ie (x,y,z)
such that x+y+z=1
, then you can simply set x=(a),y=(b),z=(c)
. So in place of (1,1,0)
you should use (.5,.5,0)
.
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
path
(90:3cm) coordinate (a) node[above] {$a$}
(210:3cm) coordinate (b) node[below left] {$b$}
(-30:3cm) coordinate (c) node[below right] {$c$};
draw [thick,green, fill=green,opacity=0.5]
(barycentric cs:a=1,b=0,c=0) --
(barycentric cs:a=1,b=0,c=1) --
(barycentric cs:a=1,b=1,c=0) -- cycle;
draw [ultra thick] (a) -- (b) -- (c) --cycle;
% set x=(a),y=(b),z=(c) and use normalized barycentric coordinates
draw[ultra thick, red, dashed, x=(a),y=(b),z=(c)]
(1,0,0) -- (.5,0,.5) -- (.5,.5,0) --cycle;
end{tikzpicture}
end{document}
Aha! I was wondering about this. So$x=(a)$
just sets the "x" coordinate inxyz
coordinates to be the vector to(a)
?
– Seamus
yesterday
1
When you setx=(a),y=(b),z=(c)
than(x,y,z)
is a point with coordinatesx.a+y.b+z.c
. That's all.
– Kpym
yesterday
@Kpym I am not angry and would like to see your other, nice answer revived. The only thing I am advocating is to refer to earlier posts by others, if they are related, something that you usually do.
– marmot
yesterday
add a comment |
If it is ok for you to use normalized barycentric coordinates, ie (x,y,z)
such that x+y+z=1
, then you can simply set x=(a),y=(b),z=(c)
. So in place of (1,1,0)
you should use (.5,.5,0)
.
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
path
(90:3cm) coordinate (a) node[above] {$a$}
(210:3cm) coordinate (b) node[below left] {$b$}
(-30:3cm) coordinate (c) node[below right] {$c$};
draw [thick,green, fill=green,opacity=0.5]
(barycentric cs:a=1,b=0,c=0) --
(barycentric cs:a=1,b=0,c=1) --
(barycentric cs:a=1,b=1,c=0) -- cycle;
draw [ultra thick] (a) -- (b) -- (c) --cycle;
% set x=(a),y=(b),z=(c) and use normalized barycentric coordinates
draw[ultra thick, red, dashed, x=(a),y=(b),z=(c)]
(1,0,0) -- (.5,0,.5) -- (.5,.5,0) --cycle;
end{tikzpicture}
end{document}
If it is ok for you to use normalized barycentric coordinates, ie (x,y,z)
such that x+y+z=1
, then you can simply set x=(a),y=(b),z=(c)
. So in place of (1,1,0)
you should use (.5,.5,0)
.
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
path
(90:3cm) coordinate (a) node[above] {$a$}
(210:3cm) coordinate (b) node[below left] {$b$}
(-30:3cm) coordinate (c) node[below right] {$c$};
draw [thick,green, fill=green,opacity=0.5]
(barycentric cs:a=1,b=0,c=0) --
(barycentric cs:a=1,b=0,c=1) --
(barycentric cs:a=1,b=1,c=0) -- cycle;
draw [ultra thick] (a) -- (b) -- (c) --cycle;
% set x=(a),y=(b),z=(c) and use normalized barycentric coordinates
draw[ultra thick, red, dashed, x=(a),y=(b),z=(c)]
(1,0,0) -- (.5,0,.5) -- (.5,.5,0) --cycle;
end{tikzpicture}
end{document}
answered yesterday
Kpym
15.7k23985
15.7k23985
Aha! I was wondering about this. So$x=(a)$
just sets the "x" coordinate inxyz
coordinates to be the vector to(a)
?
– Seamus
yesterday
1
When you setx=(a),y=(b),z=(c)
than(x,y,z)
is a point with coordinatesx.a+y.b+z.c
. That's all.
– Kpym
yesterday
@Kpym I am not angry and would like to see your other, nice answer revived. The only thing I am advocating is to refer to earlier posts by others, if they are related, something that you usually do.
– marmot
yesterday
add a comment |
Aha! I was wondering about this. So$x=(a)$
just sets the "x" coordinate inxyz
coordinates to be the vector to(a)
?
– Seamus
yesterday
1
When you setx=(a),y=(b),z=(c)
than(x,y,z)
is a point with coordinatesx.a+y.b+z.c
. That's all.
– Kpym
yesterday
@Kpym I am not angry and would like to see your other, nice answer revived. The only thing I am advocating is to refer to earlier posts by others, if they are related, something that you usually do.
– marmot
yesterday
Aha! I was wondering about this. So
$x=(a)$
just sets the "x" coordinate in xyz
coordinates to be the vector to (a)
?– Seamus
yesterday
Aha! I was wondering about this. So
$x=(a)$
just sets the "x" coordinate in xyz
coordinates to be the vector to (a)
?– Seamus
yesterday
1
1
When you set
x=(a),y=(b),z=(c)
than (x,y,z)
is a point with coordinates x.a+y.b+z.c
. That's all.– Kpym
yesterday
When you set
x=(a),y=(b),z=(c)
than (x,y,z)
is a point with coordinates x.a+y.b+z.c
. That's all.– Kpym
yesterday
@Kpym I am not angry and would like to see your other, nice answer revived. The only thing I am advocating is to refer to earlier posts by others, if they are related, something that you usually do.
– marmot
yesterday
@Kpym I am not angry and would like to see your other, nice answer revived. The only thing I am advocating is to refer to earlier posts by others, if they are related, something that you usually do.
– marmot
yesterday
add a comment |
You can also use insert path
to abbreviate the coordinates.
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}[bcs/.style args={#1|#2|#3}{insert path={--(barycentric
cs:a=#1,b=#2,c=#3)}}]
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
draw [thick,green, fill=green,opacity=0.5] (a)
[bcs={1|0|1},bcs={1|1|0}] -- cycle;
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
Another thing you could do is to locally change the TikZ parser. Then the whole path really boils down to
begin{scope}[bary={a}{b}{c}]
draw [thick,green, fill=green,opacity=0.5]
(1,0,0) -- (1,0,1) -- (1,1,0) -- cycle;
end{scope}
where bary={a}{b}{c}
install the barycentric coordinate system in the scope (we don't want it everywhere) and you really just have to specify the three numbers.
documentclass[tikz,border=3.14mm]{standalone}
makeatletter % https://tex.stackexchange.com/a/365418/121799
tikzset{bary/.code n args={3}{
deftikz@parse@splitxyz##1##2##3,##4,{%
def@next{tikz@scan@one@point##1(barycentric cs:#1=##2,#2=##3,#3=##4)}%
}}}
makeatother
begin{document}
begin{tikzpicture}
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
begin{scope}[bary={a}{b}{c}]
draw [thick,green, fill=green,opacity=0.5]
(1,0,0) -- (1,0,1) -- (1,1,0) -- cycle;
end{scope}
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
Every time I read your answers on TikZ I say to myself I have to study the user guide. I'm afraid the amount of new tools there I never read about!!
– Sigur
yesterday
@Sigur This impression never fades away, regardless how long you read it. ;-)
– marmot
yesterday
I was thinking about this too, but usinginsert path={(barycentric cs:a=#1,b=#2,c=#3)}
do not work at the end of the path. For this reason you added--
in theinsert path
, I suppose. But now you can only draw straight lines :(
– Kpym
yesterday
@Kpym Yes, that's true. This great answer comes with a sort of coordinate system parser, which one may adopt to this situation here. Anyway, I added yet another possibility that changes the TikZ parser locally.
– marmot
yesterday
add a comment |
You can also use insert path
to abbreviate the coordinates.
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}[bcs/.style args={#1|#2|#3}{insert path={--(barycentric
cs:a=#1,b=#2,c=#3)}}]
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
draw [thick,green, fill=green,opacity=0.5] (a)
[bcs={1|0|1},bcs={1|1|0}] -- cycle;
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
Another thing you could do is to locally change the TikZ parser. Then the whole path really boils down to
begin{scope}[bary={a}{b}{c}]
draw [thick,green, fill=green,opacity=0.5]
(1,0,0) -- (1,0,1) -- (1,1,0) -- cycle;
end{scope}
where bary={a}{b}{c}
install the barycentric coordinate system in the scope (we don't want it everywhere) and you really just have to specify the three numbers.
documentclass[tikz,border=3.14mm]{standalone}
makeatletter % https://tex.stackexchange.com/a/365418/121799
tikzset{bary/.code n args={3}{
deftikz@parse@splitxyz##1##2##3,##4,{%
def@next{tikz@scan@one@point##1(barycentric cs:#1=##2,#2=##3,#3=##4)}%
}}}
makeatother
begin{document}
begin{tikzpicture}
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
begin{scope}[bary={a}{b}{c}]
draw [thick,green, fill=green,opacity=0.5]
(1,0,0) -- (1,0,1) -- (1,1,0) -- cycle;
end{scope}
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
Every time I read your answers on TikZ I say to myself I have to study the user guide. I'm afraid the amount of new tools there I never read about!!
– Sigur
yesterday
@Sigur This impression never fades away, regardless how long you read it. ;-)
– marmot
yesterday
I was thinking about this too, but usinginsert path={(barycentric cs:a=#1,b=#2,c=#3)}
do not work at the end of the path. For this reason you added--
in theinsert path
, I suppose. But now you can only draw straight lines :(
– Kpym
yesterday
@Kpym Yes, that's true. This great answer comes with a sort of coordinate system parser, which one may adopt to this situation here. Anyway, I added yet another possibility that changes the TikZ parser locally.
– marmot
yesterday
add a comment |
You can also use insert path
to abbreviate the coordinates.
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}[bcs/.style args={#1|#2|#3}{insert path={--(barycentric
cs:a=#1,b=#2,c=#3)}}]
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
draw [thick,green, fill=green,opacity=0.5] (a)
[bcs={1|0|1},bcs={1|1|0}] -- cycle;
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
Another thing you could do is to locally change the TikZ parser. Then the whole path really boils down to
begin{scope}[bary={a}{b}{c}]
draw [thick,green, fill=green,opacity=0.5]
(1,0,0) -- (1,0,1) -- (1,1,0) -- cycle;
end{scope}
where bary={a}{b}{c}
install the barycentric coordinate system in the scope (we don't want it everywhere) and you really just have to specify the three numbers.
documentclass[tikz,border=3.14mm]{standalone}
makeatletter % https://tex.stackexchange.com/a/365418/121799
tikzset{bary/.code n args={3}{
deftikz@parse@splitxyz##1##2##3,##4,{%
def@next{tikz@scan@one@point##1(barycentric cs:#1=##2,#2=##3,#3=##4)}%
}}}
makeatother
begin{document}
begin{tikzpicture}
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
begin{scope}[bary={a}{b}{c}]
draw [thick,green, fill=green,opacity=0.5]
(1,0,0) -- (1,0,1) -- (1,1,0) -- cycle;
end{scope}
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
You can also use insert path
to abbreviate the coordinates.
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}[bcs/.style args={#1|#2|#3}{insert path={--(barycentric
cs:a=#1,b=#2,c=#3)}}]
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
draw [thick,green, fill=green,opacity=0.5] (a)
[bcs={1|0|1},bcs={1|1|0}] -- cycle;
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
Another thing you could do is to locally change the TikZ parser. Then the whole path really boils down to
begin{scope}[bary={a}{b}{c}]
draw [thick,green, fill=green,opacity=0.5]
(1,0,0) -- (1,0,1) -- (1,1,0) -- cycle;
end{scope}
where bary={a}{b}{c}
install the barycentric coordinate system in the scope (we don't want it everywhere) and you really just have to specify the three numbers.
documentclass[tikz,border=3.14mm]{standalone}
makeatletter % https://tex.stackexchange.com/a/365418/121799
tikzset{bary/.code n args={3}{
deftikz@parse@splitxyz##1##2##3,##4,{%
def@next{tikz@scan@one@point##1(barycentric cs:#1=##2,#2=##3,#3=##4)}%
}}}
makeatother
begin{document}
begin{tikzpicture}
coordinate (a) at (90:3cm);
coordinate (b) at (210:3cm);
coordinate (c) at (-30:3cm);
node [above] at (a) {$a$};
node [below left] at (b) {$b$};
node [below right] at (c) {$c$};
begin{scope}[bary={a}{b}{c}]
draw [thick,green, fill=green,opacity=0.5]
(1,0,0) -- (1,0,1) -- (1,1,0) -- cycle;
end{scope}
draw [ultra thick] (a) -- (b) -- (c) --cycle;
end{tikzpicture}
end{document}
edited yesterday
answered yesterday
marmot
88.9k4102191
88.9k4102191
Every time I read your answers on TikZ I say to myself I have to study the user guide. I'm afraid the amount of new tools there I never read about!!
– Sigur
yesterday
@Sigur This impression never fades away, regardless how long you read it. ;-)
– marmot
yesterday
I was thinking about this too, but usinginsert path={(barycentric cs:a=#1,b=#2,c=#3)}
do not work at the end of the path. For this reason you added--
in theinsert path
, I suppose. But now you can only draw straight lines :(
– Kpym
yesterday
@Kpym Yes, that's true. This great answer comes with a sort of coordinate system parser, which one may adopt to this situation here. Anyway, I added yet another possibility that changes the TikZ parser locally.
– marmot
yesterday
add a comment |
Every time I read your answers on TikZ I say to myself I have to study the user guide. I'm afraid the amount of new tools there I never read about!!
– Sigur
yesterday
@Sigur This impression never fades away, regardless how long you read it. ;-)
– marmot
yesterday
I was thinking about this too, but usinginsert path={(barycentric cs:a=#1,b=#2,c=#3)}
do not work at the end of the path. For this reason you added--
in theinsert path
, I suppose. But now you can only draw straight lines :(
– Kpym
yesterday
@Kpym Yes, that's true. This great answer comes with a sort of coordinate system parser, which one may adopt to this situation here. Anyway, I added yet another possibility that changes the TikZ parser locally.
– marmot
yesterday
Every time I read your answers on TikZ I say to myself I have to study the user guide. I'm afraid the amount of new tools there I never read about!!
– Sigur
yesterday
Every time I read your answers on TikZ I say to myself I have to study the user guide. I'm afraid the amount of new tools there I never read about!!
– Sigur
yesterday
@Sigur This impression never fades away, regardless how long you read it. ;-)
– marmot
yesterday
@Sigur This impression never fades away, regardless how long you read it. ;-)
– marmot
yesterday
I was thinking about this too, but using
insert path={(barycentric cs:a=#1,b=#2,c=#3)}
do not work at the end of the path. For this reason you added --
in the insert path
, I suppose. But now you can only draw straight lines :(– Kpym
yesterday
I was thinking about this too, but using
insert path={(barycentric cs:a=#1,b=#2,c=#3)}
do not work at the end of the path. For this reason you added --
in the insert path
, I suppose. But now you can only draw straight lines :(– Kpym
yesterday
@Kpym Yes, that's true. This great answer comes with a sort of coordinate system parser, which one may adopt to this situation here. Anyway, I added yet another possibility that changes the TikZ parser locally.
– marmot
yesterday
@Kpym Yes, that's true. This great answer comes with a sort of coordinate system parser, which one may adopt to this situation here. Anyway, I added yet another possibility that changes the TikZ parser locally.
– marmot
yesterday
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%2f468551%2ftikz-specifying-barycentric-coordinates-using-just-lists-of-numbers%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