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
sqrt((x-xp)+(y-yp)+(z-zp))<=radios
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)
and
(abs(y-centery) <= halfedge)
{/* point is in square... */ }
You should have no difficulty extending this to 3D.
Good Hunting!
RD
Math Central is supported by the University of Regina and The Pacific Institute for the Mathematical Sciences.