<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Check the drawing direction of a polyline in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/check-the-drawing-direction-of-a-polyline/m-p/2562009#M68992</link>
    <description>Herbert your formula has 1 too many loops.&lt;BR /&gt;
You are getting the area of triangles and the total should be double the actual area of the pline.&lt;BR /&gt;
The divide by 2 step is not needed for this function, so is not used&lt;BR /&gt;
&lt;BR /&gt;
int count=pline.NumberOfVertices-1;&lt;BR /&gt;
Point2d p1, p2;&lt;BR /&gt;
for(int i = 0;i &amp;lt; count;i++)&lt;BR /&gt;
{ &lt;BR /&gt;
p1=pline.GetPoint2dAt(i);&lt;BR /&gt;
p2=pline.GetPoint2dAt(i+1);&lt;BR /&gt;
Sum = Sum + ((p1.X * p2.Y) - (p1.Y * p2.X));&lt;BR /&gt;
}&lt;BR /&gt;
p1 = p2;&lt;BR /&gt;
p2 = pline.GetPoint2dAt(0);&lt;BR /&gt;
Sum = Sum + ((p1.X * p2.Y) - (p1.Y * p2.X));</description>
    <pubDate>Sat, 26 Sep 2009 22:15:52 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-09-26T22:15:52Z</dc:date>
    <item>
      <title>Check the drawing direction of a polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-the-drawing-direction-of-a-polyline/m-p/2562006#M68989</link>
      <description>Hi,&lt;BR /&gt;
how can I find the drawing direction of a (closed) polyline with c#? Is there a property or method available or does one have a code snippet &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
TIA&lt;BR /&gt;
Herbert</description>
      <pubDate>Thu, 24 Sep 2009 14:54:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-the-drawing-direction-of-a-polyline/m-p/2562006#M68989</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-09-24T14:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Check the drawing direction of a polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-the-drawing-direction-of-a-polyline/m-p/2562007#M68990</link>
      <description>h.putz@eurogis.de wrote:&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; how can I find the drawing direction of a (closed) polyline with c#?&lt;BR /&gt;
&amp;gt;  Is there a property or method available or does one have a code &lt;BR /&gt;
&amp;gt; snippet &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Calculate the area (yourself),  I think it's called Double Meridian&lt;BR /&gt;
Distance.  If the result is negative, your polyline is counterclockwise.&lt;BR /&gt;
&lt;BR /&gt;
Terry</description>
      <pubDate>Thu, 24 Sep 2009 15:22:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-the-drawing-direction-of-a-polyline/m-p/2562007#M68990</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-09-24T15:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Check the drawing direction of a polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-the-drawing-direction-of-a-polyline/m-p/2562008#M68991</link>
      <description>Terry,&lt;BR /&gt;
&lt;BR /&gt;
Am Thu, 24 Sep 2009 15:22:17 +0000 schrieb Terry W. Dotson:&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; h.putz@eurogis.de wrote:&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;&amp;gt; how can I find the drawing direction of a (closed) polyline with c#?&lt;BR /&gt;
&amp;gt;&amp;gt;  Is there a property or method available or does one have a code &lt;BR /&gt;
&amp;gt;&amp;gt; snippet &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Calculate the area (yourself),  I think it's called Double Meridian&lt;BR /&gt;
&amp;gt; Distance.  If the result is negative, your polyline is counterclockwise.&lt;BR /&gt;
&lt;BR /&gt;
thank you for your hint,&lt;BR /&gt;
&lt;BR /&gt;
this is working:&lt;BR /&gt;
&lt;BR /&gt;
/// &lt;SUMMARY&gt;&lt;BR /&gt;
/// Methode GetAreaDMD( Polyline oPoly)&lt;BR /&gt;
///     Berechnet die Fläche eines geschlossenen Polygons nach der&lt;BR /&gt;
///     DoubleMeridianDistance-Methode&lt;BR /&gt;
///     (-(x1*y2)-(x2*y3)-...(xn*y1)+(y1*x2)+(y2*x3)+...(yn*x1))/2&lt;BR /&gt;
/// &lt;/SUMMARY&gt;&lt;BR /&gt;
/// &lt;OBJECT&gt;&lt;PARAM name="oPoly" /&gt;&lt;BR /&gt;
/// 	oPoly ist eine AutoCAD-Polylinie&lt;BR /&gt;
/// &lt;BR /&gt;
/// &lt;RETURNS&gt;&lt;BR /&gt;
/// Flächenwert als Double&lt;BR /&gt;
///     nArea &amp;gt; 0 --&amp;gt; Fläche im Uhrzeigersinn gezeichnet&lt;BR /&gt;
///     nArea &amp;lt; 0 --&amp;gt; Fläche gegen den Urzeigersinn gezeichnet&lt;BR /&gt;
/// &lt;/RETURNS&gt;&lt;BR /&gt;
private double GetAreaDMD(Polyline oPoly)&lt;BR /&gt;
{&lt;BR /&gt;
    int nPoints;&lt;BR /&gt;
    double nArea;&lt;BR /&gt;
    nPoints = oPoly.NumberOfVertices-1;  // -1 weil Nullbasiert&lt;BR /&gt;
    nArea = 0.00;&lt;BR /&gt;
&lt;BR /&gt;
    for (int i=0; i &amp;lt; nPoints; i++)&lt;BR /&gt;
    {&lt;BR /&gt;
      nArea -= (oPoly.GetPoint2dAt(i).X*oPoly.GetPoint2dAt(i+1).Y);&lt;BR /&gt;
      nArea += (oPoly.GetPoint2dAt(i).Y*oPoly.GetPoint2dAt(i+1).X);&lt;BR /&gt;
    } // for ...&lt;BR /&gt;
    nArea -= (oPoly.GetPoint2dAt(nPoints).X*oPoly.GetPoint2dAt(0).Y);&lt;BR /&gt;
    nArea += (oPoly.GetPoint2dAt(nPoints).Y*oPoly.GetPoint2dAt(0).X);&lt;BR /&gt;
&lt;BR /&gt;
    return nArea/2;&lt;BR /&gt;
} // GetAreaDMD()&lt;BR /&gt;
&lt;BR /&gt;
Bye&lt;BR /&gt;
Herbert&lt;/OBJECT&gt;</description>
      <pubDate>Fri, 25 Sep 2009 14:23:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-the-drawing-direction-of-a-polyline/m-p/2562008#M68991</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-09-25T14:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Check the drawing direction of a polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-the-drawing-direction-of-a-polyline/m-p/2562009#M68992</link>
      <description>Herbert your formula has 1 too many loops.&lt;BR /&gt;
You are getting the area of triangles and the total should be double the actual area of the pline.&lt;BR /&gt;
The divide by 2 step is not needed for this function, so is not used&lt;BR /&gt;
&lt;BR /&gt;
int count=pline.NumberOfVertices-1;&lt;BR /&gt;
Point2d p1, p2;&lt;BR /&gt;
for(int i = 0;i &amp;lt; count;i++)&lt;BR /&gt;
{ &lt;BR /&gt;
p1=pline.GetPoint2dAt(i);&lt;BR /&gt;
p2=pline.GetPoint2dAt(i+1);&lt;BR /&gt;
Sum = Sum + ((p1.X * p2.Y) - (p1.Y * p2.X));&lt;BR /&gt;
}&lt;BR /&gt;
p1 = p2;&lt;BR /&gt;
p2 = pline.GetPoint2dAt(0);&lt;BR /&gt;
Sum = Sum + ((p1.X * p2.Y) - (p1.Y * p2.X));</description>
      <pubDate>Sat, 26 Sep 2009 22:15:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-the-drawing-direction-of-a-polyline/m-p/2562009#M68992</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-09-26T22:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Check the drawing direction of a polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-the-drawing-direction-of-a-polyline/m-p/2562010#M68993</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
this one works with polyline arc segments too&lt;BR /&gt;
&lt;BR /&gt;
{code}public double PlineAlgebraicArea(Polyline pl)&lt;BR /&gt;
{&lt;BR /&gt;
    Point2d p0 = pl.GetPoint2dAt(0);&lt;BR /&gt;
    double area = 0.0;&lt;BR /&gt;
    double bulge = pl.GetBulgeAt(0);&lt;BR /&gt;
    int last = pl.NumberOfVertices - 1;&lt;BR /&gt;
    double tmpArea;&lt;BR /&gt;
&lt;BR /&gt;
    if (bulge != 0.0)&lt;BR /&gt;
    {&lt;BR /&gt;
        CircularArc2d arc = pl.GetArcSegment2dAt(0);&lt;BR /&gt;
        double arcRadius = arc.Radius;&lt;BR /&gt;
        double arcAngle = 4.0 * Math.Atan(bulge);&lt;BR /&gt;
        area += ArcAlgebraicArea(arcRadius, arcAngle);&lt;BR /&gt;
    }&lt;BR /&gt;
    for (int i = 1; i &amp;lt; last; i++)&lt;BR /&gt;
    {&lt;BR /&gt;
        area += TriangleAlgebricArea(p0, pl.GetPoint2dAt(i), pl.GetPoint2dAt(i + 1));&lt;BR /&gt;
        bulge = pl.GetBulgeAt(i);&lt;BR /&gt;
        if (bulge != 0.0)&lt;BR /&gt;
        {&lt;BR /&gt;
            CircularArc2d arc = pl.GetArcSegment2dAt(i);&lt;BR /&gt;
            double arcRadius = arc.Radius;&lt;BR /&gt;
            double arcAngle = 4.0 * Math.Atan(bulge);&lt;BR /&gt;
            area += ArcAlgebraicArea(arcRadius, arcAngle);&lt;BR /&gt;
        }&lt;BR /&gt;
    }&lt;BR /&gt;
    bulge = pl.GetBulgeAt(last);&lt;BR /&gt;
    if (bulge != 0.0)&lt;BR /&gt;
    {&lt;BR /&gt;
        CircularArc2d arc = pl.GetArcSegment2dAt(last);&lt;BR /&gt;
        double arcRadius = arc.Radius;&lt;BR /&gt;
        double arcAngle = 4.0 * Math.Atan(bulge);&lt;BR /&gt;
        area += ArcAlgebraicArea(arcRadius, arcAngle);&lt;BR /&gt;
    }&lt;BR /&gt;
    return area;&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
public double TriangleAlgebraicArea(Point2d p0, Point2d p1, Point2d p2)&lt;BR /&gt;
{&lt;BR /&gt;
    return (((p1.X - p0.X) * (p2.Y - p0.Y)) - ((p2.X - p0.X) * (p1.Y - p0.Y))) / 2.0;&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
public double ArcAlgebraicArea(double rad, double ang)&lt;BR /&gt;
{&lt;BR /&gt;
    return rad * rad * (ang - Math.Sin(ang)) / 2.0;&lt;BR /&gt;
}{code}</description>
      <pubDate>Sun, 27 Sep 2009 08:09:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-the-drawing-direction-of-a-polyline/m-p/2562010#M68993</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2009-09-27T08:09:41Z</dc:date>
    </item>
  </channel>
</rss>

