Using tikz to draw graph with multiple edges between each other - tikz

I am trying to draw a (undirected) graph using the Tikz package, such that there exist multiple edges between some nodes in the graph. Is it possible to do such a thing? I tried the following code to try and get atleast two edges between the nodes, but to no avail:
\begin{tikzpicture}
[scale=.8,auto=left,every node/.style={circle,fill=blue!20}]
\node (nA) at (1,10) {A};
\node (nB) at (9,10) {B};
\node (nC) at (5,8) {C};
\node (nD) at (5,6) {D};
\foreach \from/\to in {nA/nC,nA/nD,nC/nB,nD/nB,nC/nA,nD/nA,nB/nD,nB/nC}
\draw (\from)--(\to);
\end{tikzpicture}
Could someone help me out with this? Thanks!

How about replace the
\draw (\from)--(\to);
with
\path (\from) edge [bend left] (\to);

Related

Cairo: How to draw a bitmap clamped to edge?

I am setting a source surface and drawing. I am getting a border of the target surface's color at the edges, if the bitmap is stretched.
I believe this is because it is interpolating at the edge with alpha=0. How can I change this so it clamps the interpolation to the colors at the edge of the source texture? This would be equivalent to GL_CLAMP_TO_EDGE in OpenGL.
I found the answer. CAIRO_EXTEND_PAD is what I needed.

How to get the intersection between the scatterred points and the circle?

I'm using canny edge detection to detect the edges of a rope and eliminate the background, then using morphological filters I'm filling these edges then thinning them to be in pixel size. The plot indicates the xy coordinates of the rope. What I need to do is to get the intersection of the scattered data (blue *) with the red circle (get the coordinates of Points (1,2,3,4).
Then I need to get the whole points coordinates from the point of intersection (point1,2,3,4) to the center,grouped as A,B,C,D.
The center of the circle, the origin of the axes, and the radius are all known.
I've tried some Matlab functions to get the four intersections points like
InterX,intersections
and also I tried to manually find the intersections
idx=find(y1-y2<eps);
but no method gives me the 4 intersection points.
Thank you in Advance
You'll need a thick circle. I presume (from your previous question) that the rope points are at contiguous integer coordinates. Using a thick circle (donut) with a width of 1 ensures you'll find at least one point in each rope end. Connected component analysis will then tell you which of these points belong to the same rope end.

Patching Delaunay Triangles

I have a number of 2D points x and y, and I need to color delaunay triangles, which have edges that exceed a certain limit. However I can't figure out how to write it down so that it would compare each edge of each triangle and add it to a vector of triangles that need to be patched. The end result is supposed to be a 3D surface, where color depends on the Z coordinate, except for the triangles that have been patched white. Any help would be great!
You can try a contour plot. With your triangles and z values find the average of each triangle.

How to draw a sphere in matlab and patch it in a 3D plot?

I have a 3D plot and I want to put a sphere in a designed position. How can I create a sphere? I expected to use patch? Can anyone help me to do this please?
You can follow this:
Consider the center is at [c1,c2,c3]. The number of faces as r.
[x,y,z] = sphere(r);
surf(x+c1, y+c2, z+c3)
These two lines of code are enough to plot a sphere using the surf command.
For instance, if C=[2,2,2] and r=30 the result is as follows:
This is a sphere of radius 1 centered at [2,2,2]. To have a sphere with an arbitrary radius R, you should multiply the [x,y,z] values by R before adding the center.

Draw a rectangle in the preview window in MATLAB

How do I draw rectangles over the detected faces in the preview window in MATLAB? I have done a program in MATLAB for face detection and this program when it is running will take one frame and detect the face in that frame and draw circles over that face. However, I need to draw rectangles in the preview window so that I can achieve a continuous face detection. Can anybody give an answer for this?
Use the rectangle command. Assuming that the figure window is already open, you can call rectangle like so:
rectangle('Position', [x y w h]);
x and y denote the column and row co-ordinate of the top left corner of your rectangle. w,h denote the width and height of the rectangle. By default, this will draw a black rectangle. If you want to change the line colour, you can do:
rectangle('Position', [x y w h], 'EdgeColor', 'c');
c would be a string of the colour you want (i.e. 'red', 'blue', 'yellow', etc.)
Hope this helps!