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.
Solved! Go to Solution.
Solved by tbrammer. Go to Solution.
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°.
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
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.
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:
.
Can't find what you're looking for? Ask the community or share your knowledge.