last day (14 days later) » 

10:43 AM
1
Q: Tikz-Draw multiple lines from/to a node

ThanosI am trying to reproduce the following image I made in "Powerpoint". Although, there is no difficulty in designing the boxes, I find it rather hard to properly position the red and black lines. One solution is to use pure coordinates, but I think that there must be an easiest way to do it, sin...

 
You can find valid answers in High level digital design in TikZ.
 
@ferahfeza : Thank you very much for your comment. I tried using \draw ($(PreAmp)!0.33!(Disc)$)--++(-90:0.5); but this move the line vertically... I don't know how to move it along the x axis. I'll edit my question to illustrate that.
 
That's because (-90:0.5) says: ''go in direction -90 degrees for 0.5cm''. Note that you're not force to use this syntax. For instance, if you say \draw ($(PreAmp)!0.33!(Disc)$)--++(-1,0); that would draw a horizontal line towards left of 1cm. And so on...
 
@ClaudioFiandrino : I want a vertical line to start at 1/3 of the yellow node. Using this \draw[very thick] ($(PreAmp)!0.33!(Disc)$)--++(0,-1); I get a vertical line, but it starts from the center.
 
then that code would never work. What you're after is \draw[very thick] ($(PreAmp.north west)!0.33!(PreAmp.north)$)--++(0,-1); or south. This is stated in my linked answer.
 
10:43 AM
@ClaudioFiandrino : Your code give a line inside the node. I used \draw[very thick] ($(PreAmp.south)!0.33!(Disc.north)$)--++(0,-1); but it does the same as \draw[very thick] ($(PreAmp)!0.33!(Disc)$)--++(0,-1);. I am seeking for something like \draw (PreAmp.south/3)--(Disc.north/3). The closest to that is \draw[very thick] ($(PreAmp.south)!0.33!(Disc.north)$)--++(0,-1); but it doesn't do what I'd expected it to do...
Hello! Thank's for your time and help!
 
Hi! The point is that \draw[very thick] ($(PreAmp.south)!0.33!(Disc.north)$)--++(0,-1); means: draw from the point which lies at 1/3 from PreAmp node to Disc Node until you reach 1 cm below.
And this is absolutely not what you want.
You want: draw from the point which lies at 1/3 from the south west anchor of PreAmp to its south east anchor.
Thus, you need to say \draw[very thick] ($(PreAmp.south west)!0.33!(PreAmp.south east)$)--++(0,-1);
Then, you still don't need this because it just draws a line of 1cm.
 
Really? I am totally confused...
`PreAmp.south` means the lower part of PreAmp while `Disc.north` means the upper part of the node, isn't that right?
 
That's right, but they are two different nodes. You first have to identify the point at 1/3, say, of a single node.
 
Oh I see! You are right!
 
Now, try \draw ($(PreAmp.south west)!0.33!(PreAmp.south east)$)coordinate (a)--(a|-Disc.north); and see what happens.
 
10:53 AM
I tried this \draw[very thick] ($(PreAmp.south west)!0.33!(PreAmp.south east)$)--($(Disc.north west)!0.33!(Disc.north east)$); but I don't get a vertical line, but a tilted one...
Oh I am sorry...I didn't see your new line!
 
Of course: that's because the trick works only if both nodes have the same dimensions. If they don't, you have to proceed with the code I posted in my previous message.
 
This works right!
 
Excellent! Next step is to understand why it works ;)
 
Thank's!!! That's great!!!
And how to control the line if it's not straight?
I think I do understand!
Firstly you define the starting point, declare it as a coordinate and then you connect the coordinate to the upper part of the Disc node.
I supposse `a|- ` draws a vertical line.
 
Not completely true. a|-Disc.north identifies the intersection between the two coordinates. Then the line is drawn.
 
11:04 AM
I see!!! I think that is clear...
I suppose you mean a "perpendicular" intersection right?
 
Exactly!
 
Great! I think I understand!!!
I also assume that `\draw ($(PreAmp.south west)!0.33!(PreAmp.south east)$)coordinate (a)--(a|-Disc.north);` is equal to `\draw ($(PreAmp.south east)!0.33!(PreAmp.south west)$)coordinate (a)--(a|-Disc.north);`
 
That's not equal. Try to draw it with another color: you will discover the difference :)
 
Yes you are right!
Now I tried to draw a horizontal line like this `\draw[red, very thick] ($(Disc.north east)!0.33!(Disc.south east)$)coordinate (c)--(c|-FIFO.west);` but I get a vertical line along the right edge of the node.
I don't understand why it's not working...
I can always use \draw ($(Disc.north east)!0.33!(Disc.south east)$) -- ($(FIFO.north west)!0.33!(FIFO.south west)$); i.e. to define the two points and connect them, but I find (c|-FIFO.west) more elegant.
 

last day (14 days later) »