Intersection of squares with curve

2 次查看(过去 30 天)
Jim
Jim 2013-3-1
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?

回答(1 个)

Matt J
Matt J 2013-3-1
编辑:Matt J 2013-3-1
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.

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by