How to make a 3d object relationship script?

Discussion in 'GPGPU Technology & Programming' started by iamnoob, May 4, 2012.

  1. iamnoob

    Newcomer

    Joined:
    May 4, 2012
    Messages:
    1
    I'm a complete programming newbie so hate me if you want to.

    Here's what I need to do:

    Make a 3D object, label/class it as Fire Sprinkler
    Make another set of 3D Objects - walls, obviously classed as walls.
    Make a set of intrinsic rules such as Fire Sprinkler objects must be at least 1 foot away from wall objects.
    Define a rule that says Fire Sprinkler objects must be at least 4 feet away from each other, but cannot be more than 15 feet away from each other..
    Have a routine automatically space Fire Sprinkler objects within the walls, while trying to space sprinkler objects as far apart as is possible while still keeping within the rules.

    I don't care how long it takes to learn this, I will devote as much time as needed. I understand I need to read books on java/c++ etc. I just can't get a grasp on what the total plan to accomplish this would look like. What comes after learning to code? Is there not some easier way than by starting from absolute scratch? Is there opensource software out there that could be used as a starting point? Is what I'm trying to do even possible with current technology?

    And I guess this is a long shot, but is there any software out there that lets you input the types of parameters I just listed and do this already?
     
  2. Davros

    Legend

    Joined:
    Jun 7, 2004
    Messages:
    12,787
    good because unless you one of those people who have a natural affinity for programming your looking at a couple of years.

    Fire Sprinkler objects must be at least 4 feet away from each other
    udk would let you do this just create a appropriate size bounding box around it
    http://udk.com/

    Have a routine automatically space Fire Sprinkler objects within the walls, while trying to space sprinkler objects as far apart as is possible while still keeping within the rules.
    cant imagine udk supporting that.
     
  3. madyasiwi

    Newcomer

    Joined:
    Oct 7, 2008
    Messages:
    182
    Sounds more like 2D problem to me.

    If you don't worry too much with piping efficiency and obstructions like concrete beams. Maybe you can start by studying circle packing algorithm.

    And look at processing as a medium to play with your algorithm.
     
  4. Davros

    Legend

    Joined:
    Jun 7, 2004
    Messages:
    12,787
    one thing that I imagine would let you define rules on object spacing is speedtree
    you'd need to tell it to place hydrant models instead of trees, No idea if there is a demo version available
     
  5. PixResearch

    Regular Subscriber

    Joined:
    May 20, 2010
    Messages:
    186
    Location:
    London, UK
    If you're just worried about placing the sprinklers on a roof (i.e. not varying their heights within the building) then it's really a 2D problem and doesn't require 3D objects, classes or labels, You are finding points on a 2D shape.

    You can also ignore the rule about staying a foot away from a wall as you just make the surface you're finding points on a foot smaller than your roof.

    Maximal Poisson Disk Sampling (MPDS) would take a surface and spread a set of points as widely as possible.

    An inefficient way of solving your problem would be to run MPDS with N points. If it spreads the points out too much so that there's a point more than your maximum distance then add more points and run it again. If all the points are within your maximum limit then reduce the number of points until they're not - that's the point where they're at maximum spread within your rules.

    Note: there's probably much more efficient ways of doing it and having a good first guess of the number of points you need would save time but it'd work.
     
  6. cjo

    cjo
    Regular

    Joined:
    Mar 31, 2010
    Messages:
    206
    I'm wondering whether the 'not more than 15ft from each other' is actually meant to be 'no point on the roof more than 7.5ft from a sprinkler' (i.e. the roof must be entirely covered). If this is a case you wouldn't be able to assume this.
     
  7. PixResearch

    Regular Subscriber

    Joined:
    May 20, 2010
    Messages:
    186
    Location:
    London, UK
    true but I read not more than 15ft from one another to mean not more than 15ft from one another ;P
     
  8. silent_guy

    Veteran

    Joined:
    Mar 7, 2006
    Messages:
    3,420
    There must be many different ways to solve this, but fundamentally this is going to be problem for which it is hard, if not impossible, to prove that you have an optimal solution.

    My way to tackle this would be something along the lines of a simulated annealing algorithm (google it) where you start with a bunch of randomly chosen sprinklers and then iteratively move them around until you have a solution with the lowest cost function.

    Now how to do this when you don't know to program? I suggest having a look at Matlab and its Global Optimization Toolbox. It will take the low level implementation details out of the picture and leave only leaves the part of modeling the cost function. That is: assign mathematical equations to the constraints you want to see validated.
     
    #8 silent_guy, May 5, 2012
    Last edited by a moderator: May 5, 2012
  9. Davros

    Legend

    Joined:
    Jun 7, 2004
    Messages:
    12,787
    Lets say he actually wants to model a large building and have something that would auto decide sprinkler locations would matlab do that ?
     
  10. silent_guy

    Veteran

    Joined:
    Mar 7, 2006
    Messages:
    3,420
    Matlab is just a programming language that comes with a vast math and algorithm related libraries. You can do pretty much anything you want with it, as long as it's not symbolic, but its byline "The Language of Technical Computing" is no accident.

    The typical way to get going with these kinds of things is to model it first with some high-level language for basic problems and iterate quickly to find something that works. Start with a room with 4 walls, see how that works. Then add a separator wall and see if your algorithm still works. Until you're satisfied that you've covered all the corner cases etc.

    Later, if you're really still into it, you can start thinking about writing something that automatically converts your Sketchup or CAD model into your mathematical model. But most people will have given up by that time.

    And if you make it past that stage and you get into performance problems, you could start to consider learning C/C++/Java and convert your Matlab script into a compiled language.

    As for auto-deciding the sprinkler position: it's not about deciding anything, it's stating the problem as problem of (#sp * 3) variables and defining a cost function that includes the distance to the wall and distance of the sprinklers to each other etc.

    You give the sprinkler positions some random initial position. Then you throw your optimizer at it. Since the cost function is going to be one with a lot of non-optimal local minima and a ton of variables, you'll need something like simulated annealing to first explore a lot of options and slow down to converge to the local minimum of the best solution up to then. That said, I'm sure that there will be other algorithms that work as well or much better.
     

Share This Page

Loading...