Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Suppose I have a closed path that looks like:

 _
| |_
|___|

I want to draw, within that path, a scaled version of it so that the centers of the two figures are the same. That is, wherever this path is located, I wan't to be able to draw a similar path within this path.

A possible solution would be to move a path by its center point. Any suggestion? Thanks!

share|improve this question
    
You could use the local bounding box feature of TikZ, however you would get then only the center of the outer rectangle of the path. Would that be ok? –  Martin Scharrer Oct 26 '11 at 16:38
    
I'm not sure, but it may do the trick in my case. How would you go for getting the center of the bounding box of a path, then? Thanks! –  Michaël Oct 26 '11 at 18:20

1 Answer 1

up vote 1 down vote accepted

If I'm understanding you correctly, you want to draw a figure, and pick a point in it (which may be the center of mass, or may not) and scale the figure down to a copy of itself, with the center of scaling at the point you chose. If this is so, you want the scale = <factor> option: put this in the \draw command for the second shape, and all the coordinates will be scaled (around the origin (0,0)) by <factor>. If you want to scale around another center, use the option shift = {(<x>, <y>)} (note the braces) first.

You have to figure out what <x> and <y> are if you want to scale around a different center. One easy out is simply to draw your big shape so that its center of mass is actually at the origin. If you don't want to compute the center of mass yourself, you can use the method I describe in my answer Finding centroid of the content in whole tikzpicture, scope or node to have TikZ do it for you.

share|improve this answer
    
Thanks Ryan! I've just found out about the "scale around" key, which is what I was searching for, but you post on the center of mass helped a lot! –  Michaël Oct 26 '11 at 18:18
    
There's a scale around key? –  Ryan Reich Oct 26 '11 at 19:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.