Post Reply 
(28S) three points are collinear ?
12-14-2013, 07:20 PM (This post was last modified: 06-15-2017 01:59 PM by Gene.)
Post: #1
(28S) three points are collinear ?
FIRST METHOD:
Code:
« C→R 1 
   4 ROLL C→R 1 
   7 ROLL C→R 1 
   {3 3} →ARRY DET 
   ABS 1E-10 <
 »
'ALIG'

A(a,a'), B(b,B'), C(c,c') are lined up if the determinant = 0
|a a' 1|
|b b' 1| = 0
|c c' 1|


SECOND METHOD: (added 26/12/2013)
A(a,a'), B(b,B'), C(c,c') are lined up if the angle (AB,AC) = 0 modulo π (in radians)

Lets find the angle (AB,AC) first
Code:

«  3 PICK - 
   ARG 
   SWAP ROT -
   ARG -
   1 SWAP R→C
   P→R ARG
 »
'ANGL'

then
Code:

«  ANGL 
   2 *
   1 SWAP R→C
   P→R ARG
   ABS 1E-10 <
 »
'ALIG'

Examples:

3: (2,2)
2: (4,1)
1: (5,3)
ALIG
1: 0 (false)

3: (2,-3)
2: (4,1)
1: (5,3)
ALIG
1: 1 (true)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)