[Gllug] Algorithm question
Pete Ryland
pdr at pdr.cx
Tue Feb 27 11:22:22 UTC 2007
On 27/02/07, John Hearns <john.hearns at streamline-computing.com> wrote:
> A stupid answer.
> Rotate your axes till the cube's faces are parallel to X/Y/Z
> Scale the axes till it has unit sides (or to extend this, scale 3 axes
> differently so XYZ faces of a cuboid are unity).
> Place one vertex at the origin.
> Apply same transformation to the coordinates of the point.
> Point's new co-ordinates are a,b,c
> If modulus (a | b | c ) > 1 then point is outside the cube.
>
> I guess figuring out the tensor to do the rotation and scaling would be
> more complicated than any sensible answer.
Exactly how I'd do it, especially if there were lots of points to
compare. The transform function wouldn't be too difficult to work
out. It all depends on what format you have the numbers in to start
with. You may have the coords of one vertex the scale and two angles.
Whatever you've got, you'd end up with something like:
[ x ]
x' = T [ ]
[ 1 ]
With T being a 4x3 matrix with the rotation part in the first 3x3 and
the translation in the last column. The rotation part can be
calculated in various ways, see pages like
http://www.euclideanspace.com/maths/algebra/matrix/orthogonal/rotation/index.htm
for more info.
Pete
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list