6
$\begingroup$

there, I encountered this problem while coding:

I generate a table in the r-z plane of cylindrical coordinates:

tbl = Flatten[Table[{r, z}, {r, 0, 1, .1}, {z, -.8, .8, .1}], 1];

and the boundary curve of the region is defined parametrically in the bispherical coordinates:

r[η_, ξ_] := (c Sin[η])/(Cosh[ξ] - Cos[η]);
z[η_, ξ_] := (c Sinh[ξ])/(Cosh[ξ] - Cos[η]);

with the constant:

c = ρ Sin[η0];(*ρ Sin[η0]*)
ρ = (2/(3 (π - η0) Cos[η0] + 3 Sin[η0] - 
  Sin[η0]^3))^(1/3);

Thus, given the fixed η0, such as η0=π/3, plot the curve:

η0=Pi/3;
ParametricPlot[{r[η0, ξ], z[η0, ξ]}, {ξ, -30, 30}, PlotRange -> All]

I want to select the points that lie inside of the region bounded by the curve and the y-axis, but I don't know how to add this condition to "Select". Please help!

$\endgroup$
  • $\begingroup$ Your curve isn't closed. I assume you want to bound the region with $x>0$ ? $\endgroup$ – Julien Kluge Oct 4 '17 at 20:12
  • $\begingroup$ yes, sorry, I didn't describe it correctly, I want the points inside of the region bounded by the curve and the y-axis $\endgroup$ – Ying Zhang Oct 4 '17 at 20:16
  • $\begingroup$ Look up RegionFunction and define your region by statements such as $0<x<1.2$ and $-X(x) < y < + X(x)$, where $X(x)$ is derived from you implicit equations. Once you have a region function you can use RegionMember applied to each point. $\endgroup$ – David G. Stork Oct 4 '17 at 20:33
  • 1
    $\begingroup$ Alternativly to Vitaliy's answer, you could also solve the equation to a $y(x)$ function as mentioned by David with xiSols = Normal[Solve[x == r[\[Eta]0, xi], xi, Reals]] ySol = z[\[Eta]0, xi] /. xiSols // Simplify $\endgroup$ – Julien Kluge Oct 4 '17 at 20:37
  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$ – Vitaliy Kaurov Oct 4 '17 at 21:00
4
$\begingroup$

As suggested i present an alternative solution.

But keep in mind, this depends on the ability to solve your implicit equations and therefore, does not work everytime. But when it works it yields a fast Boolean condition.

We doing the following. Consider your set of equations, depending on the parameter $\xi$.

$$(x,y)=(r(\xi),z(\xi))$$

We solve the first one for the parameter and plug this solution into the other equation. We hope to not only solve this, but to get at least 2 equations which bound your region in $y(x)$.

$$\xi=r^{-1}(x)\\ y(x)=z(r^{-1}(x))$$

We can get the $r^{-1}$ with

xiSols=Normal[Solve[x==r[\[Eta]0,xi],xi,Reals]]

which has two solutions. So we've already won. Plug this into the second equation:

{ySolL,ySolR}=z[\[Eta]0,xi]/.xiSols//Simplify

The sign signals us that ySolL < ySolR and therefore ySolL < y < ySolR

We can easily check this:

RegionPlot[ySolL<=y<=ySolR,{x,0,1.2},{y,-1,1}]

regionplot

So you could now either:

  • create a region and check with Element
  • Use the fast Boolean condition directly ySolL<=y<=ySolR && x > 0

    tblIn=Select[tbl,(ySolL<=y<=ySolR&&x>=0)/.{x->#[[1]],y->#[[2]]}&];

    With the plot

    Show[RegionPlot[ySolL <= y <= ySolR, {x, 0, 1.2}, {y, -1, 1}], ListPlot[tblIn]]

    Blockquote

$\endgroup$
  • $\begingroup$ +1. The lack of an upper limit on $x$ becomes a problem if there are points to the right of the region though. $\endgroup$ – C. E. Oct 4 '17 at 21:34
7
$\begingroup$

You should parametrize your region. c looks to me like sort of a radius and it will help to cut off half a plane.

tbl=Flatten[Table[{r,z},{r,0,1,.1},{z,-.8,.8,.1}],1];

r[η_,ξ_, c_]:=(c Sin[η])/(Cosh[ξ]-Cos[η]);
z[η_,ξ_, c_]:=(c Sinh[ξ])/(Cosh[ξ]-Cos[η]);

η0=Pi/3;
ρ=(2/(3 (π-η0) Cos[η0]+3 Sin[η0]-Sin[η0]^3))^(1/3);
c0=ρ Sin[η0];

rig = Region[ParametricRegion[{{r[η0, ξ, c], z[η0, ξ, c]}, 
    0 < c < c0}, {{ξ, -30, 30}, c}], Epilog -> Point[tbl]]

enter image description here

sel=Select[tbl,RegionMember[rig,#]&];

Region[ParametricRegion[{{r[η0,ξ,c],z[η0,ξ,c]},0<c<c0},
{{ξ,-30,30},c}],Epilog->Point[sel]]

enter image description here

I am not sure why some points look they slightly sticking out of the region, - might be drawing imprecision or an issue. You should check this as I am out of time, I hope it's a start.

$\endgroup$
  • 1
    $\begingroup$ beat me by just 1 minute. $\endgroup$ – Julien Kluge Oct 4 '17 at 20:35
  • 1
    $\begingroup$ @JulienKluge it is always a race here ;-) $\endgroup$ – Vitaliy Kaurov Oct 4 '17 at 20:37
  • 1
    $\begingroup$ Many appreciations to both of you! $\endgroup$ – Ying Zhang Oct 4 '17 at 20:38
  • $\begingroup$ @Julien Kluge can you please also post your answer if you're not using the same method? $\endgroup$ – Ying Zhang Oct 4 '17 at 20:38
  • 1
    $\begingroup$ @JulienKluge yes if you are doing something else feel free to post. $\endgroup$ – Vitaliy Kaurov Oct 4 '17 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.