MATLAB Answers

Intersection of squares with curve

1 view (last 30 days)
Jim
Jim on 1 Mar 2013
Say that you have a collection of squares in 2D, defined by their corner points (A,B,C,D) and having a unique identifying number ID. You also have a 2D curve defined implicitly as the zero level of a levelset function.
The first task is to find which squares intersect the curve. The second is to find what are the intersection points.
Can someone point out how should one go on to solve this problem?

  0 Comments

Sign in to comment.

Answers (1)

Matt J
Matt J on 1 Mar 2013
Edited: Matt J on 1 Mar 2013
Denoting the level set function by L(x,y), you could use LSQNONLIN (if you have it) to minimize L^2(x,y) subject to the constraint that x,y lie in a particular square. If the minimum is achieved at an L^2 value close to zero, you know it intersects that square.
To find the intersection points, you can then minimize L^2 subject to the constraint that it lie a line segment bounding the square and, similarly, see if you get a minimum L^2 close to zero. If so, the solution is an intersection point on that edge. This scheme works if the curve can only intersect an edge of a square at most once. There is no way, other than perhaps graphically, to determine multiple intersection points at an edge with any reliability.

  0 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!