Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Division of a square

Subject: Division of a square

From: nandkumar siraskar

Date: 16 May, 2011 17:39:05

Message: 1 of 7

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

Subject: Division of a square

From: Matt J

Date: 16 May, 2011 18:19:03

Message: 2 of 7

"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?
=========

With the result being what? You want the vertices of all the smaller squares? If so, organized, how?

Subject: Division of a square

From: ImageAnalyst

Date: 16 May, 2011 19:54:59

Message: 3 of 7

On May 16, 1:39 pm, "nandkumar siraskar" <kingmou...@gmail.com> wrote:
> 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

------------------------------------
How about using imresize (in the Image Processing Toolbox)? It has a
number of options for how the additional elements are created
(nearest, interpolated, etc.).

Subject: Division of a square

From: Roger Stafford

Date: 16 May, 2011 20:15:04

Message: 4 of 7

"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 = (((n-I).*(n-J))*V1+(I.*(n-J))*V2+(I.*J)*V3+((n-I).*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

Subject: Division of a square

From: nand mourya

Date: 16 May, 2011 20:25:20

Message: 5 of 7

"Matt J" wrote in message <iqrpqn$782$1@newscl01ah.mathworks.com>...
> "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?
> =========
>
> With the result being what? You want the vertices of all the smaller squares? If so, organized, how?
==============

I want a matrix (i X3) that contains all the points (vertices of all the squares obtained from the division).

Subject: Division of a square

From: Roger Stafford

Date: 17 May, 2011 03:25:03

Message: 6 of 7

"nand mourya" wrote in message <iqs17g$40o$1@newscl01ah.mathworks.com>...
> I want a matrix (i X3) that contains all the points (vertices of all the squares obtained from the division).
- - - - - - - - - -
  Based on your comment, perhaps you want the array in the form of V before the reshape is performed:

 [I,J] = meshgrid(0:n,0:n); I = I(:); J = J(:);
 V = (((n-I).*(n-J))*V1+(I.*(n-J))*V2+(I.*J)*V3+((n-I).*J)*V4)/n^2;

V will then be a (n+1)^2 by 3 array in which the rows are vertices.

Roger Stafford

Subject: Division of a square

From: nand mourya

Date: 17 May, 2011 17:49:03

Message: 7 of 7

"Roger Stafford" wrote in message <iqspqf$fm6$1@newscl01ah.mathworks.com>...
> "nand mourya" wrote in message <iqs17g$40o$1@newscl01ah.mathworks.com>...
> > I want a matrix (i X3) that contains all the points (vertices of all the squares obtained from the division).
> - - - - - - - - - -
> Based on your comment, perhaps you want the array in the form of V before the reshape is performed:
>
> [I,J] = meshgrid(0:n,0:n); I = I(:); J = J(:);
> V = (((n-I).*(n-J))*V1+(I.*(n-J))*V2+(I.*J)*V3+((n-I).*J)*V4)/n^2;
>
> V will then be a (n+1)^2 by 3 array in which the rows are vertices.
>
> Roger Stafford

thanks..i guess it will work...

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us