How can I position a node in the center of an arbitrary path
documentclass{article}
usepackage{lmodern}
usepackage{tikz,times}
usetikzlibrary{positioning}
begin{document}
begin{tikzpicture}[scale=.3]
draw [thick] (0,6) rectangle (18,4) node [pos=.5] {like this};
draw [thick] (0,2) -- (18,2) -- (18,0) -- (0,0) -- cycle;
%draw [thick] (0,2) -- (18,2) -- (18,0) -- (0,0) -- cycle node [pos=.5] {A};
draw [thick] (0,-3) -- (4, -3) -- (5, -5) -- (-1, -5) -- (3, -4) -- cycle;
%draw [thick] (0,-3) -- (4, -3) -- (5, -5) -- (-1, -5) -- (3, -4) -- cycle node [pos=.5] {B};
end{tikzpicture}
end{document}
In this document i have three paths. the first is a simple rectangle where positioning a node in the center is easy (node [pos=.5] {like this}
). However when it comes to doing this for any path i am unable to do it.
How do i get a node that is centered. Optionally, one that is also inside the path, though this would not be as important.
tikz-pgf positioning
add a comment |
documentclass{article}
usepackage{lmodern}
usepackage{tikz,times}
usetikzlibrary{positioning}
begin{document}
begin{tikzpicture}[scale=.3]
draw [thick] (0,6) rectangle (18,4) node [pos=.5] {like this};
draw [thick] (0,2) -- (18,2) -- (18,0) -- (0,0) -- cycle;
%draw [thick] (0,2) -- (18,2) -- (18,0) -- (0,0) -- cycle node [pos=.5] {A};
draw [thick] (0,-3) -- (4, -3) -- (5, -5) -- (-1, -5) -- (3, -4) -- cycle;
%draw [thick] (0,-3) -- (4, -3) -- (5, -5) -- (-1, -5) -- (3, -4) -- cycle node [pos=.5] {B};
end{tikzpicture}
end{document}
In this document i have three paths. the first is a simple rectangle where positioning a node in the center is easy (node [pos=.5] {like this}
). However when it comes to doing this for any path i am unable to do it.
How do i get a node that is centered. Optionally, one that is also inside the path, though this would not be as important.
tikz-pgf positioning
Do you want the node appear in the center of a shape or half the way along the path?
– Tobi
Feb 8 '13 at 14:24
In the center of a shape.
– Johannes
Feb 8 '13 at 14:37
See my answer below. It seems possible to get the center of a rectangle surrounding all points but that isn’t necessarily the “center of mass”
– Tobi
Feb 8 '13 at 14:38
add a comment |
documentclass{article}
usepackage{lmodern}
usepackage{tikz,times}
usetikzlibrary{positioning}
begin{document}
begin{tikzpicture}[scale=.3]
draw [thick] (0,6) rectangle (18,4) node [pos=.5] {like this};
draw [thick] (0,2) -- (18,2) -- (18,0) -- (0,0) -- cycle;
%draw [thick] (0,2) -- (18,2) -- (18,0) -- (0,0) -- cycle node [pos=.5] {A};
draw [thick] (0,-3) -- (4, -3) -- (5, -5) -- (-1, -5) -- (3, -4) -- cycle;
%draw [thick] (0,-3) -- (4, -3) -- (5, -5) -- (-1, -5) -- (3, -4) -- cycle node [pos=.5] {B};
end{tikzpicture}
end{document}
In this document i have three paths. the first is a simple rectangle where positioning a node in the center is easy (node [pos=.5] {like this}
). However when it comes to doing this for any path i am unable to do it.
How do i get a node that is centered. Optionally, one that is also inside the path, though this would not be as important.
tikz-pgf positioning
documentclass{article}
usepackage{lmodern}
usepackage{tikz,times}
usetikzlibrary{positioning}
begin{document}
begin{tikzpicture}[scale=.3]
draw [thick] (0,6) rectangle (18,4) node [pos=.5] {like this};
draw [thick] (0,2) -- (18,2) -- (18,0) -- (0,0) -- cycle;
%draw [thick] (0,2) -- (18,2) -- (18,0) -- (0,0) -- cycle node [pos=.5] {A};
draw [thick] (0,-3) -- (4, -3) -- (5, -5) -- (-1, -5) -- (3, -4) -- cycle;
%draw [thick] (0,-3) -- (4, -3) -- (5, -5) -- (-1, -5) -- (3, -4) -- cycle node [pos=.5] {B};
end{tikzpicture}
end{document}
In this document i have three paths. the first is a simple rectangle where positioning a node in the center is easy (node [pos=.5] {like this}
). However when it comes to doing this for any path i am unable to do it.
How do i get a node that is centered. Optionally, one that is also inside the path, though this would not be as important.
tikz-pgf positioning
tikz-pgf positioning
edited Feb 8 '13 at 14:54
percusse
137k14256494
137k14256494
asked Feb 8 '13 at 14:10
JohannesJohannes
6291615
6291615
Do you want the node appear in the center of a shape or half the way along the path?
– Tobi
Feb 8 '13 at 14:24
In the center of a shape.
– Johannes
Feb 8 '13 at 14:37
See my answer below. It seems possible to get the center of a rectangle surrounding all points but that isn’t necessarily the “center of mass”
– Tobi
Feb 8 '13 at 14:38
add a comment |
Do you want the node appear in the center of a shape or half the way along the path?
– Tobi
Feb 8 '13 at 14:24
In the center of a shape.
– Johannes
Feb 8 '13 at 14:37
See my answer below. It seems possible to get the center of a rectangle surrounding all points but that isn’t necessarily the “center of mass”
– Tobi
Feb 8 '13 at 14:38
Do you want the node appear in the center of a shape or half the way along the path?
– Tobi
Feb 8 '13 at 14:24
Do you want the node appear in the center of a shape or half the way along the path?
– Tobi
Feb 8 '13 at 14:24
In the center of a shape.
– Johannes
Feb 8 '13 at 14:37
In the center of a shape.
– Johannes
Feb 8 '13 at 14:37
See my answer below. It seems possible to get the center of a rectangle surrounding all points but that isn’t necessarily the “center of mass”
– Tobi
Feb 8 '13 at 14:38
See my answer below. It seems possible to get the center of a rectangle surrounding all points but that isn’t necessarily the “center of mass”
– Tobi
Feb 8 '13 at 14:38
add a comment |
2 Answers
2
active
oldest
votes
The pos
option (or midway
) referres alway to the last two given coordinates, i.e. in a path (0,0) -- (1,2) -- (3,-1)
with the node at the end it will be centered on the line between (1,2)
and (3,-1)
:
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
draw (0,0) -- (1,2) -- (3,-1) node [pos=0.5, fill=red] {x};
end{tikzpicture}
end{document}
To center a node in a shape with more edges you may use a hint: Create the path and then let a node fit
all it’s coordinates (using the fit
library). The content of this node will be centered in a rectangle (add draw=red
to the node to see it) surrounding all given coordinates:
documentclass{article}
usepackage{tikz}
usetikzlibrary{fit}
begin{document}
begin{tikzpicture}
draw (-1,2) -- (5,2) -- (3,0) -- (0,0) -- cycle;
node [fit={(-1,2) (5,2) (3,0) (0,0)}] {x};
end{tikzpicture}
end{document}
In some cases it could be an alternativ to use the shape
library and set the dimensions to a node instead of using coordinates. To get the exact dimensions use inner sep=0pt
additionally, otherwise the size will be advanced by the value of inner sep
, which is 0.3333em ba default
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.geometric}
begin{document}
begin{tikzpicture}
node [minimum width=2cm, minimum height=1cm,draw] {x};
node at (3,0) [minimum width=2cm, minimum height=1cm,draw,trapezium] {x};
node at (6,0) [minimum width=2cm, minimum height=1cm,draw,ellipse] {x};
end{tikzpicture}
end{document}
When you use a node it is even possible to align another node on top of it by giving the first one a name:
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.geometric}
begin{document}
begin{tikzpicture}
node (my node) [minimum width=2cm, minimum height=1cm,draw] {x};
node at (my node) [minimum width=1cm, minimum height=1cm,draw,circle] {X};
end{tikzpicture}
end{document}
If you want a path with a geometric shape it’s maybe better to use a shaped node with a given width. See my edit.
– Tobi
Feb 8 '13 at 14:41
add a comment |
I was trying to do something similar and ended up finding this question.
But I found a different solution for the case where your path is polygonal (i.e., formed by straight lines connecting points): Give a name to every vertex in your path (say using coordinate
), and latter use a barycentric coordinate system and create a node with weight one for each point in the path. That is the center of mass. Bellow is a minimal example.
documentclass{standalone}
usepackage{pgf,tikz}
begin{document}
begin{tikzpicture}
draw(0,0) coordinate (P1) -- (1,2) coordinate(P2) -- (3,-1) coordinate(P3) -- (2,-1) coordinate (P4) -- cycle;%%the cycle here does not affect the position of X.
coordinate (center) at (barycentric cs:P1=1,P2=1,P3=1,P4=1) {};
node at (center) {X};
end{tikzpicture}
end{document}
1
But be careful about having colinear vertices in the path. This will affect the position of the center, as the weight are in the vertices.
– Fabricio
Feb 2 at 2:56
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%2f97359%2fhow-can-i-position-a-node-in-the-center-of-an-arbitrary-path%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The pos
option (or midway
) referres alway to the last two given coordinates, i.e. in a path (0,0) -- (1,2) -- (3,-1)
with the node at the end it will be centered on the line between (1,2)
and (3,-1)
:
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
draw (0,0) -- (1,2) -- (3,-1) node [pos=0.5, fill=red] {x};
end{tikzpicture}
end{document}
To center a node in a shape with more edges you may use a hint: Create the path and then let a node fit
all it’s coordinates (using the fit
library). The content of this node will be centered in a rectangle (add draw=red
to the node to see it) surrounding all given coordinates:
documentclass{article}
usepackage{tikz}
usetikzlibrary{fit}
begin{document}
begin{tikzpicture}
draw (-1,2) -- (5,2) -- (3,0) -- (0,0) -- cycle;
node [fit={(-1,2) (5,2) (3,0) (0,0)}] {x};
end{tikzpicture}
end{document}
In some cases it could be an alternativ to use the shape
library and set the dimensions to a node instead of using coordinates. To get the exact dimensions use inner sep=0pt
additionally, otherwise the size will be advanced by the value of inner sep
, which is 0.3333em ba default
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.geometric}
begin{document}
begin{tikzpicture}
node [minimum width=2cm, minimum height=1cm,draw] {x};
node at (3,0) [minimum width=2cm, minimum height=1cm,draw,trapezium] {x};
node at (6,0) [minimum width=2cm, minimum height=1cm,draw,ellipse] {x};
end{tikzpicture}
end{document}
When you use a node it is even possible to align another node on top of it by giving the first one a name:
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.geometric}
begin{document}
begin{tikzpicture}
node (my node) [minimum width=2cm, minimum height=1cm,draw] {x};
node at (my node) [minimum width=1cm, minimum height=1cm,draw,circle] {X};
end{tikzpicture}
end{document}
If you want a path with a geometric shape it’s maybe better to use a shaped node with a given width. See my edit.
– Tobi
Feb 8 '13 at 14:41
add a comment |
The pos
option (or midway
) referres alway to the last two given coordinates, i.e. in a path (0,0) -- (1,2) -- (3,-1)
with the node at the end it will be centered on the line between (1,2)
and (3,-1)
:
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
draw (0,0) -- (1,2) -- (3,-1) node [pos=0.5, fill=red] {x};
end{tikzpicture}
end{document}
To center a node in a shape with more edges you may use a hint: Create the path and then let a node fit
all it’s coordinates (using the fit
library). The content of this node will be centered in a rectangle (add draw=red
to the node to see it) surrounding all given coordinates:
documentclass{article}
usepackage{tikz}
usetikzlibrary{fit}
begin{document}
begin{tikzpicture}
draw (-1,2) -- (5,2) -- (3,0) -- (0,0) -- cycle;
node [fit={(-1,2) (5,2) (3,0) (0,0)}] {x};
end{tikzpicture}
end{document}
In some cases it could be an alternativ to use the shape
library and set the dimensions to a node instead of using coordinates. To get the exact dimensions use inner sep=0pt
additionally, otherwise the size will be advanced by the value of inner sep
, which is 0.3333em ba default
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.geometric}
begin{document}
begin{tikzpicture}
node [minimum width=2cm, minimum height=1cm,draw] {x};
node at (3,0) [minimum width=2cm, minimum height=1cm,draw,trapezium] {x};
node at (6,0) [minimum width=2cm, minimum height=1cm,draw,ellipse] {x};
end{tikzpicture}
end{document}
When you use a node it is even possible to align another node on top of it by giving the first one a name:
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.geometric}
begin{document}
begin{tikzpicture}
node (my node) [minimum width=2cm, minimum height=1cm,draw] {x};
node at (my node) [minimum width=1cm, minimum height=1cm,draw,circle] {X};
end{tikzpicture}
end{document}
If you want a path with a geometric shape it’s maybe better to use a shaped node with a given width. See my edit.
– Tobi
Feb 8 '13 at 14:41
add a comment |
The pos
option (or midway
) referres alway to the last two given coordinates, i.e. in a path (0,0) -- (1,2) -- (3,-1)
with the node at the end it will be centered on the line between (1,2)
and (3,-1)
:
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
draw (0,0) -- (1,2) -- (3,-1) node [pos=0.5, fill=red] {x};
end{tikzpicture}
end{document}
To center a node in a shape with more edges you may use a hint: Create the path and then let a node fit
all it’s coordinates (using the fit
library). The content of this node will be centered in a rectangle (add draw=red
to the node to see it) surrounding all given coordinates:
documentclass{article}
usepackage{tikz}
usetikzlibrary{fit}
begin{document}
begin{tikzpicture}
draw (-1,2) -- (5,2) -- (3,0) -- (0,0) -- cycle;
node [fit={(-1,2) (5,2) (3,0) (0,0)}] {x};
end{tikzpicture}
end{document}
In some cases it could be an alternativ to use the shape
library and set the dimensions to a node instead of using coordinates. To get the exact dimensions use inner sep=0pt
additionally, otherwise the size will be advanced by the value of inner sep
, which is 0.3333em ba default
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.geometric}
begin{document}
begin{tikzpicture}
node [minimum width=2cm, minimum height=1cm,draw] {x};
node at (3,0) [minimum width=2cm, minimum height=1cm,draw,trapezium] {x};
node at (6,0) [minimum width=2cm, minimum height=1cm,draw,ellipse] {x};
end{tikzpicture}
end{document}
When you use a node it is even possible to align another node on top of it by giving the first one a name:
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.geometric}
begin{document}
begin{tikzpicture}
node (my node) [minimum width=2cm, minimum height=1cm,draw] {x};
node at (my node) [minimum width=1cm, minimum height=1cm,draw,circle] {X};
end{tikzpicture}
end{document}
The pos
option (or midway
) referres alway to the last two given coordinates, i.e. in a path (0,0) -- (1,2) -- (3,-1)
with the node at the end it will be centered on the line between (1,2)
and (3,-1)
:
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
draw (0,0) -- (1,2) -- (3,-1) node [pos=0.5, fill=red] {x};
end{tikzpicture}
end{document}
To center a node in a shape with more edges you may use a hint: Create the path and then let a node fit
all it’s coordinates (using the fit
library). The content of this node will be centered in a rectangle (add draw=red
to the node to see it) surrounding all given coordinates:
documentclass{article}
usepackage{tikz}
usetikzlibrary{fit}
begin{document}
begin{tikzpicture}
draw (-1,2) -- (5,2) -- (3,0) -- (0,0) -- cycle;
node [fit={(-1,2) (5,2) (3,0) (0,0)}] {x};
end{tikzpicture}
end{document}
In some cases it could be an alternativ to use the shape
library and set the dimensions to a node instead of using coordinates. To get the exact dimensions use inner sep=0pt
additionally, otherwise the size will be advanced by the value of inner sep
, which is 0.3333em ba default
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.geometric}
begin{document}
begin{tikzpicture}
node [minimum width=2cm, minimum height=1cm,draw] {x};
node at (3,0) [minimum width=2cm, minimum height=1cm,draw,trapezium] {x};
node at (6,0) [minimum width=2cm, minimum height=1cm,draw,ellipse] {x};
end{tikzpicture}
end{document}
When you use a node it is even possible to align another node on top of it by giving the first one a name:
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.geometric}
begin{document}
begin{tikzpicture}
node (my node) [minimum width=2cm, minimum height=1cm,draw] {x};
node at (my node) [minimum width=1cm, minimum height=1cm,draw,circle] {X};
end{tikzpicture}
end{document}
edited Feb 8 '13 at 14:48
answered Feb 8 '13 at 14:36
TobiTobi
38.2k8131256
38.2k8131256
If you want a path with a geometric shape it’s maybe better to use a shaped node with a given width. See my edit.
– Tobi
Feb 8 '13 at 14:41
add a comment |
If you want a path with a geometric shape it’s maybe better to use a shaped node with a given width. See my edit.
– Tobi
Feb 8 '13 at 14:41
If you want a path with a geometric shape it’s maybe better to use a shaped node with a given width. See my edit.
– Tobi
Feb 8 '13 at 14:41
If you want a path with a geometric shape it’s maybe better to use a shaped node with a given width. See my edit.
– Tobi
Feb 8 '13 at 14:41
add a comment |
I was trying to do something similar and ended up finding this question.
But I found a different solution for the case where your path is polygonal (i.e., formed by straight lines connecting points): Give a name to every vertex in your path (say using coordinate
), and latter use a barycentric coordinate system and create a node with weight one for each point in the path. That is the center of mass. Bellow is a minimal example.
documentclass{standalone}
usepackage{pgf,tikz}
begin{document}
begin{tikzpicture}
draw(0,0) coordinate (P1) -- (1,2) coordinate(P2) -- (3,-1) coordinate(P3) -- (2,-1) coordinate (P4) -- cycle;%%the cycle here does not affect the position of X.
coordinate (center) at (barycentric cs:P1=1,P2=1,P3=1,P4=1) {};
node at (center) {X};
end{tikzpicture}
end{document}
1
But be careful about having colinear vertices in the path. This will affect the position of the center, as the weight are in the vertices.
– Fabricio
Feb 2 at 2:56
add a comment |
I was trying to do something similar and ended up finding this question.
But I found a different solution for the case where your path is polygonal (i.e., formed by straight lines connecting points): Give a name to every vertex in your path (say using coordinate
), and latter use a barycentric coordinate system and create a node with weight one for each point in the path. That is the center of mass. Bellow is a minimal example.
documentclass{standalone}
usepackage{pgf,tikz}
begin{document}
begin{tikzpicture}
draw(0,0) coordinate (P1) -- (1,2) coordinate(P2) -- (3,-1) coordinate(P3) -- (2,-1) coordinate (P4) -- cycle;%%the cycle here does not affect the position of X.
coordinate (center) at (barycentric cs:P1=1,P2=1,P3=1,P4=1) {};
node at (center) {X};
end{tikzpicture}
end{document}
1
But be careful about having colinear vertices in the path. This will affect the position of the center, as the weight are in the vertices.
– Fabricio
Feb 2 at 2:56
add a comment |
I was trying to do something similar and ended up finding this question.
But I found a different solution for the case where your path is polygonal (i.e., formed by straight lines connecting points): Give a name to every vertex in your path (say using coordinate
), and latter use a barycentric coordinate system and create a node with weight one for each point in the path. That is the center of mass. Bellow is a minimal example.
documentclass{standalone}
usepackage{pgf,tikz}
begin{document}
begin{tikzpicture}
draw(0,0) coordinate (P1) -- (1,2) coordinate(P2) -- (3,-1) coordinate(P3) -- (2,-1) coordinate (P4) -- cycle;%%the cycle here does not affect the position of X.
coordinate (center) at (barycentric cs:P1=1,P2=1,P3=1,P4=1) {};
node at (center) {X};
end{tikzpicture}
end{document}
I was trying to do something similar and ended up finding this question.
But I found a different solution for the case where your path is polygonal (i.e., formed by straight lines connecting points): Give a name to every vertex in your path (say using coordinate
), and latter use a barycentric coordinate system and create a node with weight one for each point in the path. That is the center of mass. Bellow is a minimal example.
documentclass{standalone}
usepackage{pgf,tikz}
begin{document}
begin{tikzpicture}
draw(0,0) coordinate (P1) -- (1,2) coordinate(P2) -- (3,-1) coordinate(P3) -- (2,-1) coordinate (P4) -- cycle;%%the cycle here does not affect the position of X.
coordinate (center) at (barycentric cs:P1=1,P2=1,P3=1,P4=1) {};
node at (center) {X};
end{tikzpicture}
end{document}
answered Feb 2 at 2:49
FabricioFabricio
314
314
1
But be careful about having colinear vertices in the path. This will affect the position of the center, as the weight are in the vertices.
– Fabricio
Feb 2 at 2:56
add a comment |
1
But be careful about having colinear vertices in the path. This will affect the position of the center, as the weight are in the vertices.
– Fabricio
Feb 2 at 2:56
1
1
But be careful about having colinear vertices in the path. This will affect the position of the center, as the weight are in the vertices.
– Fabricio
Feb 2 at 2:56
But be careful about having colinear vertices in the path. This will affect the position of the center, as the weight are in the vertices.
– Fabricio
Feb 2 at 2:56
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f97359%2fhow-can-i-position-a-node-in-the-center-of-an-arbitrary-path%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
Do you want the node appear in the center of a shape or half the way along the path?
– Tobi
Feb 8 '13 at 14:24
In the center of a shape.
– Johannes
Feb 8 '13 at 14:37
See my answer below. It seems possible to get the center of a rectangle surrounding all points but that isn’t necessarily the “center of mass”
– Tobi
Feb 8 '13 at 14:38