MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Moving an outsider to the closest point on the boundary

Respected subscribers of comp.soft-sys.math.mathematica,

I have bumped into a problem which I cannot solve.
I have defined a distance function d(x,y) that says True in the inside
of the closed geometry of interest and False outside. Initially there
are some points inside the geometry. My iterating algorithm moves those
points. Some stay inside while others may drift away over the boundary
to the outside. I would like to select those outsiders and move them
back in, however, not in any way: I want to move them back to the
closest point on the boundary. (This corresponds to the physical
analogy of my work.)
Here is an example of a unit circle as defined geometry and two points:

d[x_, y_] := x^2 + y^2 = 1
p1 = {0, 0};
p2 = {.8, .5};
dp1 = {-.1, -.1};
dp2 = {.3, -.3};

  If[d[x, y], 1, -1],
  {x, -2, 2}, {y, -2, 2},
  PlotPoints -> 100,
  Mesh -> False,
  Epilog -> {
      Hue[0], PointSize[.02],
      Point /@ {p1, p2},
      Hue[.6], Point /@ {p1 + dp1, p2 + dp2}

After each iteration I would like to correct the set of points by doing
something like this:

If[! d @@ #, bringBack[#, d2 @@ #], #] & /@ {p1 + dp1, p2 + dp2}

{{-0.1, -0.1}, bringBack[{1.1, 0.2}, d2[1.1, 0.2]]}

But, bringBack?

Thank you for your time and suggestions,
Borut Levart

  • Prev by Date: Re: Returning an empty sequence
  • Next by Date: What we from 1^Infinity, Infinity^0, and similar stuff
  • Previous by thread: Adding matrices for use in NDSolve input
  • Next by thread: What we from 1^Infinity, Infinity^0, and similar stuff