in reply to Re: Closed geometry: a train track problem
in thread Closed geometry: a train track problem

Oh yes, delta x,y,alfa is the clever sight, but, it cannot describe possibility of track crossing (without some special crossing piece), for instance.
  • Comment on Re^2: Closed geometry: a train track problem

Replies are listed 'Best First'.
Re^3: Closed geometry: a train track problem
by samizdat (Vicar) on Jan 04, 2006 at 13:31 UTC
    "an exercise for the reader"... :)

    Okay, how about this: calculate some intermediate points, and store them in an x-y array. If a new piece tries to add points that are too close to an old point, it's a collision.

    Actually, I like Dr. Mu's concept of transforming successful closed layouts, although I wouldn't necessarily do it as a 'parsing problem' because that gets trickier as pieces become more varied in length, angle and radius. Either the programmer or the program need to figure out what transformations work geometrically, and I'd much rather it be the program. Heesh's right to focus on successful layouts rather than random ones, because that will give you more solutions more quickly. Won't be as entertaining to watch, though! :D

    Don Wilde
    "There's more than one level to any answer."
      Yes, Dr. Mu's concept is exact, but it need to solve collisions, too - generally, problems related with real dimensions of pieces.
      Ad intermediate points - imho, my concept of occupied squares is better (but not exhausting collision problems), of course, when it is possible to split every piece into set of square-unit.
        We're pretty much saying the same thing, but I think my points-along solution will serve better when we get to bridge clearances and things like that. For instance, let's say we have a bridge that crosses at a non-right angle. With my version, it's very easy to get a pretty accurate location and angle of the crossing so that we can ensure that the bridge abutments are far enough away from the center of the bottom track to clear. This requires that we know things like the length of the bridge and the width of the bridge as well, but it seems like it would be extremely difficult to figure any of this out without knowing the location and angle of the crossing.

        With mine, the allowable distance is the same in every direction, set by one constant. With yours, it's different for side-by-side sqaures from corner-to-corner ones. Since calculating sqrt(delx**2+dely**2) < limit is what computers are supposed to be good at, I rest my case. :D

        Don Wilde
        "There's more than one level to any answer."
Re^3: Closed geometry: a train track problem
by DrHyde (Prior) on Jan 05, 2006 at 10:09 UTC
    If the only crossings permitted are bridges, then this is easily solved. A bridge needs:
    • an ascending section of track;
    • a raised but level section of track;
    • a descending section of track
    Presumably you have a set number of support pieces for these, so if you allow any piece of track to alter the z co-ordinate if necessary, you just need to keep track of how many times you've changed z (ie how many ascents and descents you have) and how many times z has remained constant but non-zero (ie how many raised level sections you have). Detecting when you need a bridge to cross over another piece of track is easy.

    If you can have flat cross-overs, then you need to model the crossover as a special case.