Choices when getIntersectionPoints Returns Two Points

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
wildspidee
Full Member
Posts: 84
Joined: Sat Nov 03, 2012 2:00 am

Choices when getIntersectionPoints Returns Two Points

Post by wildspidee » Sat Feb 14, 2015 5:00 pm

I am using the intersection of two circles to define the end point of two lines with fixed length and variable angle. When the circles intersect, there are actually two points of intersection. Fortunately, QCAD is currently choosing the preferred location. My concern is that QCAD may not always do so and choose the other intersection, which will not produce the desired results.

I've attached the drawing file for your reference. How is QCAD choosing one point over the other and is there anything I can do to restrict the selection to the leftmost intersection point?

Thank you for your time,
Lori
Attachments
CircleIntersections.dxf
(107.27 KiB) Downloaded 431 times

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Choices when getIntersectionPoints Returns Two Points

Post by andrew » Mon Feb 16, 2015 2:09 pm

The function getIntersectionPoints actually returns an array of all solutions (hence the plural).
var c1 = new RCircle(new RVector( 0,50), 100);
var c2 = new RCircle(new RVector(25,50), 100);

var solutions = c1.getIntersectionPoints(c2);

for (var i=0; i<solutions.length; i++) {
    qDebug(solutions);
}


Output:
Debug:    RVector(12.5, -49.2157, 0) 
Debug:    RVector(12.5, 149.216, 0)

wildspidee
Full Member
Posts: 84
Joined: Sat Nov 03, 2012 2:00 am

Re: Choices when getIntersectionPoints Returns Two Points

Post by wildspidee » Mon Feb 16, 2015 4:51 pm

Andrew,

I should have qDebug(ged) it to see the return. Didn't even occur to me. I have to constantly remind myself that all the data is there for the taking, I just have to ask.

I can write a conditional to choose the point, if more than one is returned, that is the smallest in the X coordinate. It should work perfectly every time.

Thank you.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”