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