0

I have a cuboid in 3D space, it is not regular at all. I do have the coordinates of its 8 vertices and my problem is how to determine a given point coordinate is inside or outside this cuboid.

I have so far though that if I can calculate the distance of the point to each of the 6 side planes then I can find out the answer. Assume I can calculate for each side the plane formula with the normal pointing out of the cuboid, then for the point to be inside all distances must be negative, right? If one of the 6 distances is positive then the point is on the outside.

Is this the shortest and simplest approach?

ilomambo
  • 103

1 Answers1

4

If you express the cuboid as $C=\cap_{k=1}^6 H_k$, where each $H_k = \{ x | \langle x, n_k \rangle \le \beta_k \}$, then $ x \in C$ iff $\langle x, n_k \rangle \le \beta_k$ for all $k$.

You also have $ x \in C^\circ$ iff $\langle x, n_k \rangle < \beta_k$ for all $k$.

(It is hard to say if this is the shortest or simplest without more information. The eight vertices or the normals may have some relationship, for example.)

copper.hat
  • 172,524
  • I am afraid that is too mathematical for me to derive some practical formulas. What more information is it you think would help to make the answer more readable for the non-mathematicians? (I come from the engineering world) – ilomambo Sep 08 '14 at 18:00
  • The $n_k$ are normals. You have $\langle x , y \rangle = x^Ty$, the inner or dot product. The $\beta_k$ come from evaluating the relevant inner product on one of the points composing a face. – copper.hat Sep 08 '14 at 18:07
  • I get it now! I did not express myself clearly enough. You did put it succintly in mathematical form, but I was asking if there is a simpler METHOD to get the answer. – ilomambo Sep 08 '14 at 19:45
  • What do you mean by simpler? Six inner products and comparisons is fairly simple. I can think of more complex schemes (the cuboid is the union of $3!=6$ simplices, and computing membership in each simplex is a $4 \times 4$ matrix multiplication). – copper.hat Sep 08 '14 at 21:23