Message 1 of 7
Not applicable
12-07-2011
11:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am having a problem using the intersectWith function to return an intersection between a circle and line, both of which are AcGe class objects. Can someone please point me in the right direction? The relevant code is below. Also, any pointers on anything else that is done incorrectly would be appreciated. I am trying to basically draw a circle, then draw a leader from the center to a chosen point, then finally draw two lines starting at the leader tip back to the circle, 90 degrees around to each side from where the leader intersects it. The problem is that it does not find any intersection points and draws instead to the origin.
TIA,
Ralph
// Create the circle
double const Pi = 3.14159265358979;
AcGePoint3d centerPt; // center point of brace circle
AcDbCircle* pBraceCircle; // pointer to brace circle
if(acedGetPoint(NULL, _T("\nSpecify brace point on roof: "), asDblArray(centerPt)))
{
float radius(4.5); // circle radius
pBraceCircle = new AcDbCircle(centerPt, AcGeVector3d::kZAxis, radius);
// Add the circle to database and close it
addToModelSpace(pBraceCircle);
pBraceCircle->close();
}
// Create the leader
AcGePoint3d supportPt; // point on wall or beam
if(acedGetPoint(asDblArray(centerPt), _T("\nSpecify support point for brace: "), asDblArray(supportPt)))
{
AcDbLeader* pLeader = new AcDbLeader();
// add the leader to database and then close it
addToModelSpace(pLeader);
pLeader->appendVertex(supportPt);
pLeader->appendVertex(centerPt);
pLeader->close();
}
// Create the lines connecting the leader tip to the circle sides
// convert the 3d points at brace and support points to 2d
AcGePoint2d supportPt2d(supportPt.x, supportPt.y);
AcGePoint2d centerPt2d(centerPt.x, centerPt.y);
// get a construction line in direction of leader and rotate 90 degrees
AcGeLineSeg2d geBraceLine(supportPt2d, centerPt2d);
AcGeLine2d gePerpLine;
geBraceLine.getPerpLine(supportPt2d, gePerpLine);
gePerpLine.rotateBy(Pi/2, centerPt2d);
// get a construction circle over brace circle
// find intersections with construction circle and line
AcGeCircArc2d geBraceCircle(centerPt2d, 4.5);
int intN; // number of intersections
AcGePoint2d intersPt1, intersPt2; // intersecting points
geBraceCircle.intersectWith(gePerpLine, intN, intersPt1, intersPt2);
// create the first line, add to database and close
AcGePoint3d StartPt1( intersPt1.x, intersPt1.y, 0);
AcDbLine* pBraceLine1 = new AcDbLine(StartPt1, supportPt);
addToModelSpace(pBraceLine1);
pBraceLine1->close();
// create the second line, add to database and close
AcGePoint3d StartPt2( intersPt2.x, intersPt2.y, 0);
AcDbLine* pBraceLine2 = new AcDbLine(StartPt2, supportPt);
addToModelSpace(pBraceLine2);
pBraceLine2->close();
Solved! Go to Solution.