[Haskell-cafe] Coplanarity or Colinearity [Was: low-cost matrix rank?]

Richard A. O'Keefe ok at cs.otago.ac.nz
Wed Apr 29 01:14:36 UTC 2015


On 26/04/2015, at 1:53 am, Mike Meyer <mwm at mired.org> wrote:
> My real problem is that I've got a list of points in R3  and want to decide if they determine a plane, meaning they are coplanar but not colinear. Similarly, given a list of points in R2, I want to verify that they aren't colinear. Both of these can be done by converting the list of points to a matrix and finding the rank of the matrix, but I only use the rank function in the definitions of colinear and coplanar.

To compute the rank of a matrix,
perform elementary row operations
until the matrix is left in echelon form;
the number of nonzero rows remaining in
the reduced matrix is the rank.

(http://www.cliffsnotes.com/math/algebra/linear-algebra/real-euclidean-vector-spaces/the-rank-of-a-matrix)

A matrix is in row echelon form when it
satisfies the following conditions:
* The first non-zero element in each row,
  called the leading entry, is 1
* Each leading entry is in a column to
  the right of the leading entry in the
  previous row
* Rows with all zero elements, if any,
  are below rows having a non-zero element.

(http://stattrek.com/matrix-algebra/echelon-transform.aspx)
Row echelon forms aren't unique, but for determining
the rank of a matrix, that doesn't matter.

Code working on a list of points left as an exercise for
the reader.



More information about the Haskell-Cafe mailing list