Thread Subject: Identifying the relative position of a grid point towards an arbitrary point.

Subject: Identifying the relative position of a grid point towards an arbitrary point.

From: Gyusok

Date: 27 Feb, 2009 21:59:02

Message: 1 of 1

Hello,
 I have a the following problem:
I want to define to position of a point in a grid, that is the one with the nearest distance towards one defined point.

as an example I have these two lines of a grid:
LineA = [ 22.3186 22.3329 22.3474 22.3618 22.3764 22.3909 22.4055 22.4202 22.4349 22.4497;
  -29.4844 -29.4707 -29.4570 -29.4433 -29.4296 -29.4159 -29.4022 -29.3885 -29.3748 -29.3611]
and
LineB =[ 22.3938 22.4083 22.4227 22.4373 22.4518 22.4665 22.4811 22.4958 22.5106 22.5254;
  -29.5838 -29.5701 -29.5563 -29.5426 -29.5288 -29.5151 -29.5014 -29.4876 -29.4739 -29.4601]
and one Point
point =[22.4269 -29.4625]

I can now plot:
>>
figure
plot(LineA(1,:), LineA(2,:), '*k', LineB(1,:), LineB(2,:), '*k' , point(1),point(2) , '*b')
grid
>>

By using the 'min'-function of matlab I can find the minimum distance and it will turn out that the point LineA(6,:) is the nearest to "point".

I need to express the position of the nearest point on one of the lines by a 2x2 Matrix of the Form:
[ 0 0;
  1 0]
Giving the position of an edge of a rectangle containing the 'point' defined be the two neighbouring lines with their entries having the same index. The "1' marks the relative position towards the 'point'-variable.
( In this case the rectangle is formed by
LineA(6), LineA(7), LineB(6), LineB(7). Hower depending on the position the rectangle would be in the other direction to contain the point.)

So far I did not succeed because for differently shaped grids, the case differentiation I made so far did not solve the problem.

hope someone can help

thanks!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
minimum Gyusok 27 Feb, 2009 22:24:07
grid Gyusok 27 Feb, 2009 22:24:07
position Gyusok 27 Feb, 2009 17:00:20
iteration Gyusok 27 Feb, 2009 17:00:20
rssFeed for this Thread

Contact us at files@mathworks.com