mark's banner

Friday, May 21, 2004

Shape Traversal

I'm finishing up the traversal technology for ALDOT's right of way application. In fact I've simplified it considerably over the J version. All we really want to do is step through the elements in a "Clockwise" direction. When a complex shape element is created, either manually or automatically MicroStation V8 requires that the elements chain from startpoint to endpoint (as did v7). But, they can progress clockwise or counter-clockwise.

So, before I can sort the elements - in right of way the point of begining will indicate where on the shape the traverse legs will start incrementing. This of course doesn't necessarilly coincide with the first element in the shape. To compensate I recreate the shape in the order I want, and if the original shape was counter-clockwise then I also step through these elements in reverse order to add them to the new complex shape.

How do I figure out if the shape progresses clockwise or counter-clockwise? I use a summation of areas which works perfectly as long as none shape legs cross one another. Here's the equation:


for k = 1 to count-1
sumarea = sumarea + (vertices(k).x * vertices(k-1).y _
- vertices(k-1).x * vertices(k).y)
next
sumarea = sumarea/2


When sumearea is positive then the shape progresses clockwise, and when negative it progresses counter-clockwise.

0 Comments:

Post a Comment

<< Home