# Divide a Set of Points along a Direction

I have a set of points in a 3d space. These Points are positioned mainly along one direction. What I need to do is to find this direction (I guess PCA may do the trick) and then split this set of points in two groups along this direction.

Let's say (I'm just making an example to explain) these points are positioned along the Y axis, all I want to do is to have one group with all the points that have the Y greater than the point P, and the other group with all the points that have the Y smaller than the point P.

P is a given point of this set. I had troubles dividing this set ALONG the main direction. I hope I made myself clear =)

-

Well if you have the main direction $\mathbf{v}$ (as 3D vector) (either known or computed by PCA) and point $\mathbf{p}$ (as 3D location vector), all you need to do is project the points onto $\mathbf{v}$ (using the standard 3D dot product) and compare this projection to that of $\mathbf{p}$:
$S_1 = \{\mathbf{q}:\mathbf{q}\cdot\mathbf{v} < \mathbf{p}\cdot\mathbf{v}\}$
$S_2 = \{\mathbf{q}:\mathbf{q}\cdot\mathbf{v} \geq \mathbf{p}\cdot\mathbf{v}\}$
In other words you create a plane through $\mathbf{p}$ with normal $\mathbf{v}$ and classify the points into those behind the plane and those in front of the plane.
For your example of $\mathbf{v}$ being just $(0, 1, 0)^T$, this gerneral case will of course reduce to just comparing the y-values of the points.