Math CentralQuandaries & Queries


Question from Ali:

hi every one
i have a problem with cube they told me to write a program that determine if a point is inside a cube
so i need the equation of the cube to do the comparison. in sphere it is easy
if u please could help me
and if u have any problem with electrical or electronics i can help u
thanks at all
yours Ali

Hi Ali:

It's easiest to check each coordinate independently:

if (abs(x-centerx) <= halfedge)
(abs(y-centery) <= halfedge)

{/* point is in square... */ }

You should have no difficulty extending this to 3D.

Good Hunting!

About Math Central


Math Central is supported by the University of Regina and The Pacific Institute for the Mathematical Sciences.
Quandaries & Queries page Home page University of Regina PIMS