Page 1 of 1

Check if three points ([RVector]) are aligned

Posted: Fri Dec 29, 2017 7:21 pm
by miro
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

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

Posted: Fri Jan 05, 2018 12:13 am
by andrew
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)) { ... }

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

Posted: Mon Jan 08, 2018 6:38 pm
by miro
Thanks it works !