"nandkumar siraskar" <kingmourya@gmail.com> wrote in message <iqrnfo$sh9$1@newscl01ah.mathworks.com>...
> Hi,
> I have a square with vertices [ 0,0,1 ; 1,0,1 ; 1,1,1; 0,1,1]
> I want to divide this square into n number of squares (lets say 16 squares). Could anyone tell me the simplest way to do it?
>
> thanks
         
Let V1, V2, V3, and V4 be 1 by 3 row vectors for the four successive vertices around a 3D square. (It's your responsibility to ensure that they are coplanar and constitute a square.)
[I,J] = meshgrid(0:n,0:n); I = I(:); J = J(:);
V = (((nI).*(nJ))*V1+(I.*(nJ))*V2+(I.*J)*V3+((nI).*J)*V4)/n^2;
V = reshape(n+1,n+1,3);
The 3D array V should constitute a grid of vertices of n^2 smaller squares within the original square. Each vertex has its three coordinates along the third dimension.
Roger Stafford
