getMiddlePoint Question

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

getMiddlePoint Question

Post by wildspidee » Fri Feb 06, 2015 7:20 pm

I'm using the middle point of a line to define a new RVector. My first inclination was to code:

Code: Select all

var mO = new RVector(lD_K.getMiddlePoint());
This created an error. I did qDebug to see if something was wrong with the line:

Code: Select all

    qDebug(lD_K + ' ldk');
    qDebug(lD_K.getMiddlePoint() + ' lD_K middle')
The results were fine:

Debug: RLine(RShape(address: "0x19d55f60"), startPoint: RVector(0, 23, 0), endPoint: RVector(15.25, 23, 0)) ldk
Debug: RVector(7.625, 23, 0) lD_K middle

I ended up doing this to solve the problem:

Code: Select all

    var temp0 = lD_K.getMiddlePoint();
    var mO = new RVector(temp0.getX(),temp0.getY());
This works fine, but I would like to understand what the problem is. You can't create a new RVector using an existing RVector?

Thank you for your time.

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

Re: getMiddlePoint Question

Post by andrew » Mon Feb 09, 2015 9:13 am

You can simply write:
var mO = lD_K.getMiddlePoint();
Since getMiddlePoint returns a vector, mO will be assigned that vector.

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

Re: getMiddlePoint Question

Post by wildspidee » Mon Feb 09, 2015 3:31 pm

Overcomplicating seems to be something I do consistently. The obvious often eludes me.

Thanks Andrew.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”