Learn R Programming

OjaNP (version 1.0-0)

hyperplane: Hyperplane Passing Through k Points in the k-dimensional Space.

Description

The function computes a \((k\!-\!1)\)-dimensional hyperplane passing through \(k\) given points in the \(k\)-dimensional space.

Usage

hyperplane(X)

Arguments

X

a numeric \(k \times k\) matrix containing \(k\) data points as rows.

Value

a vector of length \((k\!+\!1)\) describing the hyperplane, see details above.

Details

A \((k\!-\!1)\)-dimensional hyperplane in \(R^k\) consists of all points \(x\) that satisfy $$d^T x + c = 0, $$ where \(d\) is a \(k\)-vector and \(c\) is a scalar. The function returns the \((k\!+\!1)\)-vector \((d,c)\). It is normalized such that the length of \(d\) equals \((k\!-\!1)!\) times the \((k\!-\!1)\)-dimensional volume of the simplex formed by the points on the plane. (If \(k = 3\), this is a triangle.) Hence this function can also easily be used to compute volumes of simplices.

The direction of \(d\), that is, whether it points towards the origin or not, is not fixed. It depends on the order of the data points within the matrix X.

If the \(k\) points do not uniquely define a \((k\!-\!1)\)-dimensional hyperplane (i.e. they lie on a \((k\!-\!2)\)-dimensional hyperplane), a vector containing zeros is returned.

Examples

Run this code
# NOT RUN {
### ----<< Example 1 >>---- : line in R^2
X <- rbind(c(4,5),c(8,2))
hyperplane(X)
# The line through the the points c(4,5) and c(8,2) is given by 
#    3*x + 4*y - 32 = 0.
# The norm of the first two components of the return value 
# of hyperplane() (i.e. the vector d above) equals the 
# distance of both points.

X <- rbind(c(8,2),c(4,5))
hyperplane(X)
# If the order of the points is changed, the direction of d 
# (see details) may also change.



### ----<< Example 2 >>---- : unit vectors in R^3
X <- diag(rep(1,3))
hyperplane(X)
# The plane passing through all three unit vectors is given by 
#   -x - y - z + 1 = 0.
# These three points form a equilateral triangle on the plane 
# with side length sqrt(2) and hence area sqrt(3)/2.
# The norm of d (see details) equals twice this number. 
# }

Run the code above in your browser using DataLab