Check if three points ([RVector]) are aligned

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

Moderator: andrew

Post Reply
miro
Newbie Member
Posts: 3
Joined: Fri Dec 29, 2017 7:13 pm

Check if three points ([RVector]) are aligned

Post by miro » Fri Dec 29, 2017 7:21 pm

Hello,

Could you tell me how can I check programatically if three points ([RVector]) are aligned.

I tried :

Code: Select all

 var pointsCheck = [pointStart, pointEnd, pointsIntersec[0]]
  var polyline = new RPolyline(pointsCheck, false)
  var isAlign = RShape.isXLineShape(polyline);
  EAction.handleUserMessage("pointsCheck : " + pointsCheck)
  EAction.handleUserMessage("isAlign : " + isAlign)
But this way doesn't work for me.

Many thanks
Miro

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

Re: Check if three points ([RVector]) are aligned

Post by andrew » Fri Jan 05, 2018 12:13 am

You could create a line from two points and then check if the third point is on the line using isOnShape:

Code: Select all

if (new RLine(p1, p2).isOnShape(p3, false)) { ... }

miro
Newbie Member
Posts: 3
Joined: Fri Dec 29, 2017 7:13 pm

Re: Check if three points ([RVector]) are aligned

Post by miro » Mon Jan 08, 2018 6:38 pm

Thanks it works !

Post Reply

Return to “QCAD Developers and Contributors”