colinear | R Documentation |
Tests if three points are colinear. The coordinates of the points have to be in homogeneous coordinates.
colinear(p1, p2, p3)
p1 |
(3 \times 1) vector of the homogeneous coordinates of point 1. |
p2 |
(3 \times 1) vector of the homogeneous coordinates of point 2. |
p3 |
(3 \times 1) vector of the homogeneous coordinates of point 3. |
TRUE
if the three points are colinear, else FALSE
.
Richter-Gebert, Jürgen (2011). Perspectives on Projective Geometry - A Guided Tour Through Real and Complex Geometry, Springer, Berlin, ISBN: 978-3-642-17285-4
# points: homogeneous coordinates p1 <- c(3,1,1) p2 <- c(0,2,1) p3 <- c(1.5,-2,1) p4 <- c(1,3,1) # homogeneous line passing through p1 and p2 l1 <- join(p1,p2) # homogeneous line passing through p3 and p3 l2 <- join(p3,p4) # homogeneous points formed by the intersection of the lines p5 <- meet(l1,l2) # test for colinearity colinear(p1, p2, p3) colinear(p1, p2, p5) colinear(p3, p4, p5) # plot plot(rbind(p1,p2,p3,p4),xlim=c(-5,5),ylim=c(-5,5),asp=1) abline(h=0,v=0,col="grey",lty=3) addLine(l1,col="red") addLine(l2,col="blue") points(t(p5),cex=1.5,pch=20,col="blue")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.