# Hyperplane problem

I am writing a space searching algorithm but, since I'm just an engineer, my maths obviously isn't great ...

I have a vector, v0, in n-dimensional space and I want to search in, say, 4 directions radially out from a point, p0, on the vector.

So, I know the vector, I know the point and I can quite easily compute the equation of the hyperplane (in an ax+by+cz+d=0 format) that is normal to the vector and on which p0 sits.

Now I want to find the vectors in the plane. Here's what I did, it doesn't seem like a very elegant way and, although it works in a 3D case, I don't see how to make it work in my real case (3 to 10 dimensions).

I found a new point, p1, on plane by arbitrarily fixing x and y and calculating z from equation of plane and then found a vector along plane by v1 = p1-p0. This gives me one of my 4 directions and times by -1 gives me another in the opposite direction.

Now to get the other two directions, I know this vector, v2 is normal to both v0 and v1 so I form two simultaneous equations from the dot product equations. I have 3 unknowns and only two equations so I arbitrarily set one coefficient, a, to 1 and solve the equations. This did give me v2 and hence my other 2 directions.

So, I'm hoping a clever maths person can tell me:
1. Is my method valid (the arbitrary setting of coeffs seems a bit dodgy!)?
2. Would it work for n-dimensional case (would I have to arbitrarily set n-2 coeffs which seems impossible?)?
3. Is there some simple, clever method out there that I could use instead?!

Justin

### Re: Hyperplane problem

Thanks rspuzio, that's really helpful to learn that what I did worked even if I didn't fully understand what I was doing!

Re the higher dimensional stuff, several of my hyperplane equations do have coefficients that are zero so I have implemented your suggestion and it seems to work fine.

But what do I do with hyperplane equations with no zero coeffs? For example, several of mine have all coeffs +/-1, such as:
x1 + x2 - x3 - x4 + x5 - x6 - 10 = 0

Can I still do something similar to get the set of vectors?

Many thanks in anticipation.

Justin

### Re: Hyperplane problem

Just had a thought, are the vectors for the +/-1 case just the 2^6 combinations of +/-1 (i.e. a hadamard matrix) except the 2 combinations that are normal to the hyperplane?

### Re: Hyperplane problem

> Re the higher dimensional stuff, several of my hyperplane
> equations do have coefficients that are zero so I have
> implemented your suggestion and it seems to work fine.
>
> But what do I do with hyperplane equations with no zero
> coeffs? For example, several of mine have all coeffs +/-1,
> such as:
> x1 + x2 - x3 - x4 + x5 - x6 - 10 = 0
>
> Can I still do something similar to get the set of vectors?

vectors by considering pairs of non-zero coefficients. That
method works even if there are no zero coefficients. For
instance, in the example you just gave, that method produces,
among others, the following solutions:

p1 - p0 = (c, -c, 0, 0, 0, 0)

p1 - p0 = (c, 0, c, 0, 0, 0)

p1 - p0 = (0, 0, 0, c, c, 0)

### Re: Hyperplane problem

OK, I misunderstood. It's working now.
Thanks,
Justin

### Re: Hyperplane problem

> Now I want to find the vectors in the plane.

Here is a simple procedure that will produce your vectors no
matter what the dimension of the space within which they lie.
As you did, let us start with the equation of the hyperplane
in the form a1 x1 + a2 x2 + . . . an xn + b = 0 and a point p0
which lies on this hyperplane.

We begin by looking to see whether any of the coefficients happen
to equal zero. If so, then we have a vector. For instance, if
a1 = 0, then we have the solution p1 - p0 = (c, 0, . . . 0)
where c can be any number, if a2 = 0, we have the solution
p1 - p0 = (0, c, . . . 0), etc.

Should only one of the coefficients differ from zero, we can
stop because the vectors described above span the hyperplane.
Otherwise, we can find more vectors by looking at pairs of
coefficients. Suppose that both a1 and a2 differ from zero.
Then we have a solution p1 - p0 = (c a2, -c a1, 0, . . ., 0)
where c can be any number. Likewise, should a1 and a3 both
differ from zero, we would have
p1 - p0 = (c a3, 0, -c a1, . . ., 0) or, should a2 and a3
differ from zero, p1 - p0 = (0, c a3, -c a2, . . . , 0), etc..

So your idea does work in any dimension. There is nothing dodgy