<?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 regarding create perpendicular ray in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12637717#M989</link>
    <description>&lt;P&gt;hi i have closed polyline in the drawing now i want to create a perpendicular ray from each line to outside polyline&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Mar 2024 13:04:55 GMT</pubDate>
    <dc:creator>jignesh.rana</dc:creator>
    <dc:date>2024-03-13T13:04:55Z</dc:date>
    <item>
      <title>regarding create perpendicular ray</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12637717#M989</link>
      <description>&lt;P&gt;hi i have closed polyline in the drawing now i want to create a perpendicular ray from each line to outside polyline&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 13:04:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12637717#M989</guid>
      <dc:creator>jignesh.rana</dc:creator>
      <dc:date>2024-03-13T13:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: regarding create perpendicular ray</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12643549#M990</link>
      <description>&lt;P&gt;So you have a closed polyline that contains only lines, right?&amp;nbsp;&lt;BR /&gt;First you have to find out whether your polyline runs clockwise (cw) or counter-clockwise (ccw).&lt;BR /&gt;This can be done easily by &lt;A href="https://en.wikipedia.org/wiki/Curve_orientation#Orientation_of_a_simple_polygon" target="_blank" rel="noopener"&gt;calculating the sum of the signed angles between the lines&lt;/A&gt;. If the sum is +2PI (+360°) it is ccw if it is -2PI (-360°) it is cw. For three &lt;FONT face="courier new,courier"&gt;AcGePoint3d p1, p2, p3&lt;/FONT&gt; the signed angle can be calculated like this:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;AcGeVector3d v12(p2-p1);
AcGeVector3d v23(p3-p2);
double signedAngle = v12.angleTo(v23, AcGeVector3d::kZAxis); // 0..2PI
if (signedAngle &amp;gt; PI)
    signedAngle -= 2*PI; // -PI..+PI
&lt;/LI-CODE&gt;
&lt;P&gt;For the ray you need a starting point &lt;FONT face="courier new,courier"&gt;pt&lt;/FONT&gt; and a direction vector &lt;FONT face="courier new,courier"&gt;v&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;Let &lt;FONT face="courier new,courier"&gt;ps&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;pe&lt;/FONT&gt; be start/endpoint of a segment.&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;AcGePoint3d ps, pe;  // in
bool ccw; // in

AcGeVector3d v, vse(pe - ps);
AcGeVector3d v(-vse.y, vse.x, vse.z); 
//v points to the left side of [ps--&amp;gt;pe] which is the outside if clockwise
if (ccw)
  v = -v;
AcGePoint3d pt(ps + 0.5*vse);
AcDbRay *ray = new AcDbRay()
ray-&amp;gt;setBasePoint(pt);
v.normalize();
ray-&amp;gt;setUnitDir(v);

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 16:01:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12643549#M990</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2024-03-15T16:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: regarding create perpendicular ray</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12647285#M991</link>
      <description>&lt;P&gt;first thing from where to take 3 points p1,p2 and p3&amp;nbsp;&lt;/P&gt;&lt;P&gt;second thing is i want to get perpendicular outside ray&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;something is missing in logic&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 07:52:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12647285#M991</guid>
      <dc:creator>jignesh.rana</dc:creator>
      <dc:date>2024-03-18T07:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: regarding create perpendicular ray</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12647334#M992</link>
      <description>&lt;P&gt;I explained:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;how to determine whether the polygon runs cw or ccw. Full function code is below.&lt;/LI&gt;
&lt;LI&gt;how to construct a ray "to the outside" when you know whether the polygon is cw or ccw.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;All you have to do is write loops and put the parts together.&lt;/P&gt;
&lt;P&gt;Each point of the closed polygon has a&amp;nbsp;predecessor and a successor. In (p1, p2, p3) p1 is the&amp;nbsp;predecessor of p2 and&amp;nbsp;p3 is it's successor. In a closed poylgon the successor of the last point is the first point. ps, pe stand for start-/endpoint of a line segment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So this is ist all together:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;// 1.) Clockwise or counter-clockwise?
double TurtleAngle(const AcGePoint3dArray &amp;amp;p)
{
	double sumAngles = 0.0; // out
	int iPrev, iNext;
	int N = p.length();
	for (int i=0; i&amp;lt;N; ++i)
	{
		iPrev = i-1;
		iNext = i+1;
		if (iPrev &amp;lt; 0)
			iPrev = N-1;
		if (iNext &amp;gt;= N)
			iNext = 0;
		const AcGePoint3d &amp;amp;p1 = p[iPrev];
		const AcGePoint3d &amp;amp;p2 = p[i];
		const AcGePoint3d &amp;amp;p3 = p[iNext];
		AcGeVector3d v12(p2-p1);
		AcGeVector3d v23(p3-p2);
		double signedAngle = v12.angleTo(v23, AcGeVector3d::kZAxis); // 0..2PI
		if (signedAngle &amp;gt; PI)
			signedAngle -= 2*PI; // -PI..+PI
		sumAngles += signedAngle
	}
	return sumAngles;
}

void CreateRays(const AcGePoint3dArray &amp;amp;p)
{
	// 1.) Clockwise or counter-clockwise?
	double ang = TurtleAngle(p);
	bool ccw = (ang &amp;gt; 0.0);

	// 2.) Create rays
	int N = p.length();
	for (int i=0; i&amp;lt;N; ++i)
	{
		int iNext = i+1;
		if (iNext &amp;gt;= N)
			iNext = 0;
		const AcGePoint3d &amp;amp;ps = p[i];
		const AcGePoint3d &amp;amp;pe = p[iNext];

		// Edited 03.20.2023: This must be within the for loop!
		AcGeVector3d v, vse(pe - ps);
		AcGeVector3d v(-vse.y, vse.x, vse.z); 
		//v points to the left side of [ps--&amp;gt;pe] which is the outside if clockwise
		if (ccw)
		  v = -v;
		AcGePoint3d pt(ps + 0.5*vse);
		AcDbRay *ray = new AcDbRay();
		ray-&amp;gt;setBasePoint(pt);
		v.normalize();
		ray-&amp;gt;setUnitDir(v);
		postToDb(ray); // add the ray to the DB
	}
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe I should have named the points p, pPrev and pNext.&lt;/P&gt;
&lt;P&gt;Just implement a loop that runs for&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 08:24:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12647334#M992</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2024-03-20T08:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: regarding create perpendicular ray</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12652745#M993</link>
      <description>&lt;P&gt;first thing is how to access pe and ps out side the loop ?&lt;/P&gt;&lt;P&gt;second thing is to consider only last pe and ps from all points(p) ?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 07:36:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12652745#M993</guid>
      <dc:creator>jignesh.rana</dc:creator>
      <dc:date>2024-03-20T07:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: regarding create perpendicular ray</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12652837#M994</link>
      <description>&lt;P&gt;The complete code is in my previous reply. See function CreateRays(AcGePoint3dArray &amp;amp;p).&lt;/P&gt;
&lt;P&gt;I just edited the code because a part of it had to be moved into the for {} loop. It should be clear now.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 08:24:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12652837#M994</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2024-03-20T08:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: regarding create perpendicular ray</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12653078#M995</link>
      <description>&lt;P&gt;but how could you assume all points (p) are in sequance ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;because it is possible if p[i] is 1st line segment start or end point in polyline and p[iNext] will be 3rd or 4th or any other no. of segment's point then how this logic will work ?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 10:44:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12653078#M995</guid>
      <dc:creator>jignesh.rana</dc:creator>
      <dc:date>2024-03-20T10:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: regarding create perpendicular ray</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12653100#M996</link>
      <description>&lt;P&gt;You wrote: "..&lt;SPAN&gt;&lt;EM&gt;&amp;nbsp;i have closed polyline in the drawing&lt;/EM&gt;". &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So you have all the polyline vertex points in a sequence.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;iNext&lt;/FONT&gt; is always the index of the vertex that follows to &lt;FONT face="courier new,courier"&gt;i&lt;/FONT&gt;: Either&lt;FONT face="courier new,courier"&gt; i+1&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;0&lt;/FONT&gt; if &lt;FONT face="courier new,courier"&gt;i&lt;/FONT&gt; is the index of the last vertex.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 11:13:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12653100#M996</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2024-03-20T11:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: regarding create perpendicular ray</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12653340#M997</link>
      <description>&lt;P&gt;thank you so much sir it' working fine&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 12:36:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/regarding-create-perpendicular-ray/m-p/12653340#M997</guid>
      <dc:creator>jignesh.rana</dc:creator>
      <dc:date>2024-03-20T12:36:00Z</dc:date>
    </item>
  </channel>
</rss>

