TikZ specifying barycentric coordinates using just lists of numbers












5















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)?










share|improve this question



























    5















    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)?










    share|improve this question

























      5












      5








      5








      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)?










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 4 at 12:21









      SeamusSeamus

      45.6k35217334




      45.6k35217334






















          3 Answers
          3






          active

          oldest

          votes


















          4














          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}


          enter image description here






          share|improve this answer
























          • Aha! I was wondering about this. So $x=(a)$ just sets the "x" coordinate in xyz coordinates to be the vector to (a)?

            – Seamus
            Jan 4 at 17:03






          • 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
            Jan 4 at 17:05











          • @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
            Jan 4 at 21:05



















          4














          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}


          enter image description here



          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}





          share|improve this answer



















          • 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
            Jan 4 at 17:07





















          4














          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}


          enter image description here



          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}





          share|improve this answer


























          • 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
            Jan 4 at 16:41











          • @Sigur This impression never fades away, regardless how long you read it. ;-)

            – marmot
            Jan 4 at 16:43











          • 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
            Jan 4 at 16:59











          • @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
            Jan 4 at 17:14











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


          }
          });














          draft saved

          draft discarded


















          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









          4














          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}


          enter image description here






          share|improve this answer
























          • Aha! I was wondering about this. So $x=(a)$ just sets the "x" coordinate in xyz coordinates to be the vector to (a)?

            – Seamus
            Jan 4 at 17:03






          • 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
            Jan 4 at 17:05











          • @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
            Jan 4 at 21:05
















          4














          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}


          enter image description here






          share|improve this answer
























          • Aha! I was wondering about this. So $x=(a)$ just sets the "x" coordinate in xyz coordinates to be the vector to (a)?

            – Seamus
            Jan 4 at 17:03






          • 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
            Jan 4 at 17:05











          • @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
            Jan 4 at 21:05














          4












          4








          4







          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}


          enter image description here






          share|improve this answer













          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}


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 4 at 15:45









          KpymKpym

          16.5k24089




          16.5k24089













          • Aha! I was wondering about this. So $x=(a)$ just sets the "x" coordinate in xyz coordinates to be the vector to (a)?

            – Seamus
            Jan 4 at 17:03






          • 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
            Jan 4 at 17:05











          • @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
            Jan 4 at 21:05



















          • Aha! I was wondering about this. So $x=(a)$ just sets the "x" coordinate in xyz coordinates to be the vector to (a)?

            – Seamus
            Jan 4 at 17:03






          • 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
            Jan 4 at 17:05











          • @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
            Jan 4 at 21:05

















          Aha! I was wondering about this. So $x=(a)$ just sets the "x" coordinate in xyz coordinates to be the vector to (a)?

          – Seamus
          Jan 4 at 17:03





          Aha! I was wondering about this. So $x=(a)$ just sets the "x" coordinate in xyz coordinates to be the vector to (a)?

          – Seamus
          Jan 4 at 17:03




          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
          Jan 4 at 17:05





          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
          Jan 4 at 17:05













          @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
          Jan 4 at 21:05





          @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
          Jan 4 at 21:05











          4














          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}


          enter image description here



          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}





          share|improve this answer



















          • 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
            Jan 4 at 17:07


















          4














          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}


          enter image description here



          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}





          share|improve this answer



















          • 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
            Jan 4 at 17:07
















          4












          4








          4







          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}


          enter image description here



          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}





          share|improve this answer













          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}


          enter image description here



          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}






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 4 at 12:26









          SigurSigur

          26k457141




          26k457141








          • 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
            Jan 4 at 17:07
















          • 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
            Jan 4 at 17:07










          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
          Jan 4 at 17:07







          +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
          Jan 4 at 17:07













          4














          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}


          enter image description here



          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}





          share|improve this answer


























          • 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
            Jan 4 at 16:41











          • @Sigur This impression never fades away, regardless how long you read it. ;-)

            – marmot
            Jan 4 at 16:43











          • 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
            Jan 4 at 16:59











          • @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
            Jan 4 at 17:14
















          4














          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}


          enter image description here



          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}





          share|improve this answer


























          • 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
            Jan 4 at 16:41











          • @Sigur This impression never fades away, regardless how long you read it. ;-)

            – marmot
            Jan 4 at 16:43











          • 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
            Jan 4 at 16:59











          • @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
            Jan 4 at 17:14














          4












          4








          4







          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}


          enter image description here



          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}





          share|improve this answer















          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}


          enter image description here



          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}






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 4 at 17:14

























          answered Jan 4 at 16:39









          marmotmarmot

          109k5133251




          109k5133251













          • 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
            Jan 4 at 16:41











          • @Sigur This impression never fades away, regardless how long you read it. ;-)

            – marmot
            Jan 4 at 16:43











          • 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
            Jan 4 at 16:59











          • @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
            Jan 4 at 17:14



















          • 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
            Jan 4 at 16:41











          • @Sigur This impression never fades away, regardless how long you read it. ;-)

            – marmot
            Jan 4 at 16:43











          • 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
            Jan 4 at 16:59











          • @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
            Jan 4 at 17:14

















          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
          Jan 4 at 16:41





          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
          Jan 4 at 16:41













          @Sigur This impression never fades away, regardless how long you read it. ;-)

          – marmot
          Jan 4 at 16:43





          @Sigur This impression never fades away, regardless how long you read it. ;-)

          – marmot
          Jan 4 at 16:43













          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
          Jan 4 at 16:59





          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
          Jan 4 at 16:59













          @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
          Jan 4 at 17:14





          @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
          Jan 4 at 17:14


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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

          Bressuire

          Cabo Verde

          Gyllenstierna