ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

boundBlock function of AcGeCurve2d in acge lib error

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
588 Views, 5 Replies

boundBlock function of AcGeCurve2d in acge lib error

const double pi = atan(1.0) * 4;

double startAngle = pi / 6;
double endAngle = pi / 3;
AcGeCircArc2d a(AcGePoint2d::kOrigin, 1, startAngle, endAngle);
AcGeBoundBlock2d bound = a.boundBlock();

AcGePoint2d minPoint;
AcGePoint2d maxPoint;
bound.getMinMaxPoints(minPoint, maxPoint);
double ra = AcGePoint2d(cos(pi / 3), sin(pi / 6)).distanceTo(minPoint);
double rb = AcGePoint2d(cos(pi / 6), sin(pi / 3)).distanceTo(maxPoint);

 

but run result is:

ra 2.0000000007769533e-08 double
rb 0.034074193710931663 double

 

I want result to be 0 and 0.

5 REPLIES 5
Message 2 of 6
tbrammer
in reply to: Anonymous

Per default the arc runs counter-clockwise from the startangle=pi/6=60° to the endangle=pi/3=30°.
So what you get is an arc that is nearly a full circle and has bounds with min=(-1,-1) and max=(1,1).
If you want the arc to run clockwise, you must call the ctor like this:

AcGeCircArc2d a(AcGePoint2d::kOrigin, 1, startAngle, endAngle, AcGeVector2d::kXAxis, Adesk::kTrue);

Alternatevely you could switch startAngle and endAngle to create a counter-clockwise arc that runs from 30° to 60°.

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 3 of 6
Anonymous
in reply to: tbrammer

This is the default parameter syntax:

 

GE_DLLEXPIMPORT AcGeCircArc2d(const AcGePoint2d& cent, double radius,
double startAngle, double endAngle,
const AcGeVector2d& refVec = AcGeVector2d::kXAxis,
Adesk::Boolean isClockWise = Adesk::kFalse);

 

from 30 ° to 60 ° it should be isClockWise = Adesk::kFalse

 

Message 4 of 6
tbrammer
in reply to: Anonymous

Oops. You're right. I mixed up start and end angle.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 5 of 6
tbrammer
in reply to: Anonymous

Sorry for the confusion.

The problem here is, that AcGeCurve2d::boundBlock() doesn't return the orthogonal bounds that you expect.

It returns the bounds of the minimal rectangle that fits around the arc (blue rectangle in the pic below).

You have to use AcGeCurve2d::orthoBoundBlock(). If you do, Your values for ra and rb will be close to 0.

bounds.png

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 6 of 6
tbrammer
in reply to: Anonymous

There is a mistake in the documentation of AcGeCurve2d::boundBlock().

It states:

The sides of the returned box are parallel to the coordinate axes.

Which is obviously wrong. The sides are parallel to the sides of a bounding box that is "somehow" aligned to the curve.

 

Although AcGeBoundBlock2d  can represent non rectangular bounding boxes (parallelogram shape)
it seems that the bounds returned from AcGeCurve2d::boundBlock() are always rectangular.

But they don't always represent the box with the minimal area. I tried the black AcGeCompositeCurve2d that

consists of three lines and got the red AcGeBoundBlock2d:

box.png.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report