<?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: Calculating bulges for circle arcs in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/calculating-bulges-for-circle-arcs/m-p/6923755#M8638</link>
    <description>&lt;P&gt;Your problem is that you calculate angle without sign. acos(c) will always return a positive number.&lt;/P&gt;
&lt;P&gt;In your equations you only have r, but not the center of the arc. It is important to know whether the arc runs clockwise or counter-clockwise from a to b.&lt;/P&gt;
&lt;P&gt;I think the bulge has to be positive for counter-clockwise and negative for clockwise arcs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;	AcGePoint3d ct; //Center point
	AcGePoint3d a, b;
	AcGeVector3d va(a-ct), vb(b-ct), normal(AcGeVector3d::kXAxis);
	double angle = va.angleTo(vb, normal);
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Mar 2017 15:40:59 GMT</pubDate>
    <dc:creator>tbrammer</dc:creator>
    <dc:date>2017-03-06T15:40:59Z</dc:date>
    <item>
      <title>Calculating bulges for circle arcs</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/calculating-bulges-for-circle-arcs/m-p/6923683#M8637</link>
      <description>&lt;P&gt;I have converted a circle into polyline segments for a program i am writing and want to calculate the bulges of each polyline in the circle. I have written the follow code to calculate the bulges of each section of the circle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;double getBulge( double r, AcGePoint3d a, AcGePoint3d b )
{

	double dist = sqrt( ( b.x - a.x ) * ( b.x - a.x ) + ( b.y - a.y ) * ( b.y - a.y ) );
	double angle = acos( ( ( 2 * r * r ) - ( dist * dist ) ) / ( 2 * r * r ) );
	double bulge = tan( angle * 0.25 );
	return bulge;
}&lt;/PRE&gt;&lt;P&gt;My problem is that sometimes the bulges are in the wrong direction on the circle see the following image. You can see that in the circles at the top of the screen shot the bulges are calculated correctly and for the circles at the bottom they are incorrect. Is there a way to figure out the direction of a bulge in a circle segment?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FORMPOST.png" style="width: 557px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/329773i03333A232D744C77/image-size/large?v=v2&amp;amp;px=999" role="button" title="FORMPOST.png" alt="FORMPOST.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FORMPOST2.png" style="width: 611px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/329775i9CCC5AD65E1FA370/image-size/large?v=v2&amp;amp;px=999" role="button" title="FORMPOST2.png" alt="FORMPOST2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 15:09:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/calculating-bulges-for-circle-arcs/m-p/6923683#M8637</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-06T15:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating bulges for circle arcs</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/calculating-bulges-for-circle-arcs/m-p/6923755#M8638</link>
      <description>&lt;P&gt;Your problem is that you calculate angle without sign. acos(c) will always return a positive number.&lt;/P&gt;
&lt;P&gt;In your equations you only have r, but not the center of the arc. It is important to know whether the arc runs clockwise or counter-clockwise from a to b.&lt;/P&gt;
&lt;P&gt;I think the bulge has to be positive for counter-clockwise and negative for clockwise arcs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;	AcGePoint3d ct; //Center point
	AcGePoint3d a, b;
	AcGeVector3d va(a-ct), vb(b-ct), normal(AcGeVector3d::kXAxis);
	double angle = va.angleTo(vb, normal);
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 15:40:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/calculating-bulges-for-circle-arcs/m-p/6923755#M8638</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2017-03-06T15:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating bulges for circle arcs</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/calculating-bulges-for-circle-arcs/m-p/6923810#M8639</link>
      <description>&lt;P&gt;Thank you that was the problem here is the updated code if anyone needs it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;double getBulge( AcDbCircle *circle, AcGePoint3d a, AcGePoint3d b )
{

	double dist = sqrt( ( b.x - a.x ) * ( b.x - a.x ) + ( b.y - a.y ) * ( b.y - a.y ) );
	double angle = atan2( a.y - circle-&amp;gt;center().y, a.x - circle-&amp;gt;center().x ) - atan2( b.y - circle-&amp;gt;center().y, b.x - circle-&amp;gt;center().x );

	if( angle &amp;lt; 0 )
	{
		//2*pi
		angle += 6.28319;
	}

	double bulge = tan( angle * 0.25 );
	return bulge;
}&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Mar 2017 15:41:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/calculating-bulges-for-circle-arcs/m-p/6923810#M8639</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-06T15:41:32Z</dc:date>
    </item>
  </channel>
</rss>

