Hi Mustafa,

That's some seriously ambitious geometry algorithm you're proposing there!  
This by no means meets your specifications, but I wonder if it might provide 
you a useful starting point or springboard for your calculations.

Using MapInfo's "Objects >> Buffer" command, you can specify a negative value 
for the buffer width which, for polygon geometries, will generate a new polygon 
inside the original.  All sides will be parallel to the original and offset by 
the specified amount.

For example:
Create Object As Buffer From Selection Width -4 Units "m" Type Spherical 
Resolution 8 Into Table Cosmetic1

As for your first question about CW or ACW direction, you could try the 
following:
1. Grab any two consecutive vertices from the polygon boundary - say 1 and 2.  
These are points (x1,y1) and (x2,y2) respectively.
2. Create a new point midway along the line 1-2, and offset D units to the 
right, in direction of travel.  This is point 3, as follows:

   x3 = (x1+x2)/2 + D((y2-y1)/sqrt((y2-y1)^2 + (x2-x1)^2)
   y3 = (y1+y2)/2 - D((x2-x1)/sqrt((y2-y1)^2 + (x2-x1)^2)
  (... would be a good idea to check my back-of-the-envelope maths here!)

3. Do a check: If polygon contains point 3, then direction of coding is 
clockwise, otherwise it's counter-clockwise.

Things to watch out for:
 - D must be expressed in the same units as your x's and y's
 - if D is "large" such that point 3 jumps right over the opposite side of the 
polygon, then point 3 will obviously not be inside the polygon, and you could 
get misleading results.  For robustness, if point 3 lies outside the polygon 
(suggesting ACW coding) try generating a point 4 which is offset to the left of 
the line 1-2 and confirm that this one lies inside the polygon.  If neither 
point 3 nor point 4 is inside the polygon ... best flag an anomaly!

I suspect there may be an alternative algorithm which uses the MapInfo 
CentroidX and CentroidY functions to identify a point which is inside the 
polygon and then work backwards from there.

Hope this helps a bit.  Good luck with the rest of it!

Cheers,
David Jerrard

Quoting Mustafa �Z�ET�N <[EMAIL PROTECTED]>:

> Hi all. I have 2 questions:
>  
> First, In MapInfo there is a polyline direction (in the object's drawing
> direction). Can we 
> programmatically (ie via Mapbasic) obtain this direction (as clockwise or
> counter-clockwise)?
>  
> Secondly, my actual purpose is: I have a parcel and I want to put a house in
> that parcel so that 
> 1) The 3 walls of the house will be 4 meters inside (and parallel to) the 3
> parcel sides.
> 2) The area of the house will be 70% of the parcel's area. (In this way the
> house will be closed up with the 4th side.)
>  
> The shape of the parcel may be rectangle, trapezoid or more complicated. I
> need a strong and general algorithm which will work with even bad parcel
> shapes. I have found it difficult to decide which  of the 2 parallel lines
> belong to the inner part of the parcel. (There are 2 identical lines which
> are 4-meters equidistant from a line.) Anyone suggest an algorithm or point
> me in the right direction?
>  
> Thanks...
> 
>               
> ---------------------------------
> Do you Yahoo!?
>  Meet the all-new My Yahoo! � Try it today! 




---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 14221

Reply via email to