# Oblique MeshGrid Selection

Discussion in 'MATLAB' started by John S Megu, Jun 18, 2006.

1. ### John S MeguGuest

Hello Matlab Users,

Wondering whether it is possible to select "meshgrid"
using an oblique area selection ( I mean not rectangle
or square, but a parellogram or any quadrilateral shape
of area). Here X & Y coordinates with oblique end points
and z coordinate vertical.

JOHN

John S Megu, Jun 18, 2006

2. ### John D'ErricoGuest

Simplest is to transform the grid to
achieve what you want.

meshgrid, then transform the domain
to some non-rectangular one with a
linear transformation.

For example,

[x,y] = meshgrid(0:.1:1);

u = x + y;
v = 2*x - y;

plot(x,y,'ro',u,v,'b+')

Or,

u = x;
v = x+y;

plot(x,y,'ro',u,v,'b+')

Note that a linear transformtion
(an affine transformation) will allow
you to rotate, translate, shear, or
stretch the original grid, or any
combination of those effects. If you
write the points (x,y) as a column
vector, then an affine transformation
can be represented as

U = A*X + b

where b is the translation vector.
Here are a couple of good references.

<http://en.wikipedia.org/wiki/Affine_transformation>

<http://mathworld.wolfram.com/AffineTransformation.html>

However, an affine transformation will
not transform the square domain from
You will need a slightly more sophisticated
transformation to do that.

A projective transformation should do
what you are looking for. It can be
represented as a bilinear form.

<http://en.wikipedia.org/wiki/Projective_transformation>

<http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/EPSRC_SSAZ/node7.html>

HTH,
John D'Erricc

John D'Errico, Jun 18, 2006