# Math Help - Paramtrize irregular area in MATLAB.

1. ## Paramtrize irregular area in MATLAB.

Hi,

Is there a way to parametrize an irregular surface (say in terms of (u,v) such that any point inside the area can be given as p(u,v)? (The boundary is defined by a series of straight line segments which form a closed area)

I have attached a very simple example of an a boundary. I have already parametrized the boundary in terms of the variable "t" where 0<t<1. I now need to do something similar for the area.

The reason I am doing this is because I am using MATLAB's optimization toolbox to optimize the connectivity of certain structures inside a particular region. So far I have just used rectangular areas which are simple to work with as all you need to do is set the upper and lower bounds for x and y. I thought if I could map an area to (u,v) I could do something similar for u and v rather than working with cartesian co-ordinates.

My apologies if this does not belong here, I thouhght this would be my best chance in the hopes that someone else has worked with irregular boundaries in computer programs before.

Regards Elbarto

Code for attached figure:
Code:
x = [0 5 4 5 1 0]'; y = [0 0 1 2 2 0]';

dx = x(2:length(x))-x(1:length(x)-1);
dy = y(2:length(x))-y(1:length(x)-1);

LENS = sqrt(dx.^2+dy.^2);
TOTAL_LEN = sum(LENS);
dt = LENS/TOTAL_LEN;
t = [0;cumsum(dt)];

subplot(2,1,1)
plot(x,y)
xlabel x
ylabel y
title 'Boundary Geometry'

subplot(2,1,2)
plot(t,x,'-',t,y,'-')
xlabel t
legend('x','y')
title('Parameterized Boundry Position')

2. Originally Posted by elbarto
Hi,

Is there a way to parametrize an irregular surface (say in terms of (u,v) such that any point inside the area can be given as p(u,v)? (The boundary is defined by a series of straight line segments which form a closed area)

I have attached a very simple example of an a boundary. I have already parametrized the boundary in terms of the variable "t" where 0<t<1. I now need to do something similar for the area.

The reason I am doing this is because I am using MATLAB's optimization toolbox to optimize the connectivity of certain structures inside a particular region. So far I have just used rectangular areas which are simple to work with as all you need to do is set the upper and lower bounds for x and y. I thought if I could map an area to (u,v) I could do something similar for u and v rather than working with cartesian co-ordinates.

My apologies if this does not belong here, I thouhght this would be my best chance in the hopes that someone else has worked with irregular boundaries in computer programs before.

Regards Elbarto

Code for attached figure:
Code:
x = [0 5 4 5 1 0]'; y = [0 0 1 2 2 0]';

dx = x(2:length(x))-x(1:length(x)-1);
dy = y(2:length(x))-y(1:length(x)-1);

LENS = sqrt(dx.^2+dy.^2);
TOTAL_LEN = sum(LENS);
dt = LENS/TOTAL_LEN;
t = [0;cumsum(dt)];

subplot(2,1,1)
plot(x,y)
xlabel x
ylabel y
title 'Boundary Geometry'

subplot(2,1,2)
plot(t,x,'-',t,y,'-')
xlabel t
legend('x','y')
title('Parameterized Boundry Position')
I'm not sure what you want to do exactly, but look at the help for inpolygon. It is effectivly the characteristic function for a polygon.

CB

3. Thanks CB.

My problem is this:

>Define a surface
>put nodes on the surface
>move the nodes around the surface (by optimising the x and y cordinates) such that the geomtric potential function is minimized (see attachment for function).

As you can imagine, defining a rectangular or circular surface (or region) is easy as I can just parramtrize x and y, but what can I do if I want to use an irgular surface?

inpolygon only tells you if your inside or outside the defined surface which I cannot use because the optimisation constraints require the constraint function to be continous so returning 0 or 1 is not an option.

Ideally I want a function that defines all possible points on the surface, but I do not know if this is possible for iregular surfaces.

Regards Elbarto