Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Recently I changed my furniture in my room and I am trying to find the best position of each part. I am sure that Mathematica could help! I read the LocatorPane, selecting multiple Locators for selecting multiple locators.

Then I made some shapes like a triangle (3 Locators), a table (4 Locators) etc. and tried to move them(each shape as a whole) in some direction.

My questions are:

  • How can one group/ungroup some of the shapes (for examples table + chairs)

  • Rotate a shape to a particular angle

  • Ensure that two sides of the same or different shapes are in parallel,vertical or tangent?

share|improve this question
Perhaps Mma isn't the best tool for interior design – Dr. belisarius Aug 12 '13 at 1:24
I agree with Belisarius. Mathematica is not the tool for this job. Any of a number of good vector drawing programs would be better. However, some the things you want are available in graphics tools found on the Graphics menu. – m_goldberg Aug 12 '13 at 1:39
While I agree that Mathematica is not the best the tool for drawing, I don't see why one would downvote this question for that reason. There could be many reasons for using Mathematica for this task, for instance because one needs the coordinates in a Mathematica centered coordinate system for further processing (calculating area, finding the best packing etc.). In the past, I have been using both the drawing tools as well as LocatorPane for quick and dirty jobs in this area and though perhaps clumsy it worked sufficiently well for my needs. – Sjoerd C. de Vries Aug 12 '13 at 5:45
@SjoerdC.deVries. I down voted because the post doesn't show any code, not because I think Mathematica is an inappropriate tool. – m_goldberg Aug 12 '13 at 13:59
@m_goldberg It is often good to clarify your downvote in a comment so that the OP knows what to improve instead of letting him guess. Your first comment doesn't provide any clue at all about code. – Sjoerd C. de Vries Aug 12 '13 at 15:24
up vote 5 down vote accepted

I think it is fun and maybe even useful for domestic purposes so this is my approach.

The following code allows you to easily manage rotation of objects. So it is reffering to your second question. I have not put this in neat DynamicModule because it is not finished, I consider it a sample piece of code :)

x = {0, 0}; y = {1, 1}; (*starting positions*)
Do[rot@i = 0, {i, 2}]; (*starting rotations*)
acc = 1;
ob[o_, id_] :=  EventHandler[Rotate[#, rot[id]] &@
                              Style[o, If[acc == id, Red, Blue]], 
                             {"MouseDown" :> (acc = id)}, 
                             PassEventsDown -> True, PassEventsUp -> True]
(*ob is wrapper for your chairs etc.*)

      {LocatorPane[Dynamic@{x, y},
                             Dynamic@ob[Rectangle[x - 1, x + 1], 1],
                             Dynamic@ob[Rectangle[y - 1, y + 1], 2]
                            }, PlotRange -> 10, ImageSize -> 500, Axes -> True]
               StringForm["Object ``", Dynamic@acc],
               InputField[Dynamic[rot[acc]], FieldSize -> 6]
              }, Center]

enter image description here

  • The active object is Red and you can switch it by click, no problem with adding SetterBar or whatever next to the plot.
  • Active object is annouced by variable acc which enables color rot and so on.
  • You can easily add other parameters which you want to be able to manage.

Experimental``AngularSlider is just for fun. It's Options do not work correctly but here it is only for it's appearance :)

Maybe it is a mess and there is not much information but I think no one is expecting that answers here will consist of complete interior design tools :)

You can use it $+$ Heike's code about multiple selection $+$ couple tiny improvements $=$ it could be something.

share|improve this answer
Good solution for selecting the active object! (+1) – cormullion Aug 12 '13 at 13:57
@Kuba I am sure that you 'll get something! This will be useful not only for domestic purposes(;)) but also geometry, drawing etc. Could you please finish your code and/or insert some geometrical or algebraic aspects in your code like measuring distances, angles, creation of a new shape, putting a shape on front/back, grouping shapes or ensuring parallel/vertical edges.... etc? – kornaros Aug 12 '13 at 15:35
Did you try this on a fresh kernel? I'm getting an error message, due to acc not being initially defined I think. – Pickett Aug 12 '13 at 15:54
@Anon You are right, thanks. – Kuba Aug 12 '13 at 15:57
@kornaros You should consider to wait with an accept, this question may provoke many great answers. I will, eventualy, improve this, but this month is horrible and I can't promise anything. Also, feel free to use this code to create more complete answer which you can post. :) – Kuba Aug 12 '13 at 16:03

I think it's an interesting question - even if I wouldn't use Mathematica for this purpose. I'm assuming you're not interested so much in the interactive drawing tools (you can group things together, but there's no numerical interactivity like you'd find in a CAD program). Sticking with 2D to start with:

chair = {Gray, Rectangle[{0, 0}, {.5, .5}]};
table = {Gray, Rectangle[{0, 0}, {1, 1}]};
bed = {Gray, Rectangle[{0, 0}, {2, 1}]};
carpet = Inset[
    CellularAutomaton[{14, {2, 1}, {1, 1}}, {{{1}}, 0}, {{{30}}}], 
    ColorFunction -> "LakeColors"]];
room = {EdgeForm[Black], FaceForm[None], Rectangle[{0, 0}, {7, 5}]};
  Translate[carpet,  {0, 0}],
  Translate[Rotate[chair, Pi],  {6.25, 4}], 
  Translate[Rotate[table, Pi/2], {6, 2.5}],
  Translate[bed, {0.1, 3.9}]
 Frame -> True]

my room

If you feel the urge to re-arrange things manually from here, then use the commands on the Graphics menu.

It's possible to add Locators and Sliders to enable some interactivity:

   Translate[carpet, {0, 0}],
   Translate[Rotate[chair, rot1], loc1], 
   Translate[Rotate[table, rot2], loc2],
   Translate[bed, {0.1, 3.9}]
  Frame -> True],
 {{rot1, 0, "Orientation of chair"}, 0, 2 Pi},
 {{rot2, 0, "Orientation of table"}, 0, 2 Pi},
 {{loc1, {0, 0}}, Locator, Appearance -> None},
 {{loc2, {0, 0}}, Locator, Appearance -> None}]

you can drag the chair and table around now. It's not looking promising though.

room service

share|improve this answer
You get my +1 for your effort of starting to answer this question (and the rug design), but I do note that you haven't answered any of the three bulleted questions. – Sjoerd C. de Vries Aug 12 '13 at 8:32
@SjoerdC.deVries :) true enough. I was going to add a Manipulate for the rotation and translate, and add a group of 4 chairs and a table - but sometimes you don't want to put too much effort into a 'proof of concept'... – cormullion Aug 12 '13 at 8:53
I also vote +1 for the answer. I like the carpet! I suppose that you can also add some texture for the the bed and table or chair. Of course, I would like to have more geometrical control on the shapes. It will be interesting to see an implementation of the Manipulate for the rotation of any selected shape or group of shapes. Also an implementation of Tooltip that inform me when two edges are in parallel etc. – kornaros Aug 12 '13 at 11:45
@kornaros It might be possible to somehow step through the objects and adjust each one with the same sliders. Amazing things are possible if people are prepared to write them. (Eg Heike's wonderful example here). I wish you luck writing such things! – cormullion Aug 12 '13 at 11:54
This would probably be a useful app! Twice in the last 15 years I've used Mathematica to lay out furniture - but just "by hand". You could group items using {items...} and then add two locators to each group, one to translate and another to rotate the group about the first. – David Park Aug 12 '13 at 13:26

Your Answer


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.