1
$\begingroup$

I am using Mathematica to plot the total potentials (which is the sum of an attractive potential field and a repulsive potential field) - This is related the Artificial Potential Field Method in Motion Planning, for example, see Wikipedia.

The attractive potential is "downhill" like a bowl and the repulsive potential is "uphill" ("spike")

I have attached the output for two cases (each case has two different viewing angles).

The first two figures are Case 1 and the last two are Case 2.

I prefer Case 2 (the last two figures) to which I have added to the Plot3D command:

ClippingStyle -> None

My problem is with the repulsive potential (the spike). There appears to some sort of "messy cylinder" (maroon in color) going through the entire spike. This is visible in View 2 of each case.

Is there anyway I can get rid of the cylinder by adding some options to Plot3D?

Case 1: View 1 Case 1: View 2 Case 2: View 1 Case 2: View 2

Edit Given below is the code for generating the plot.

(*Assignments*)
r = 0.5;

q = 1;

xmax = 70;
ymax = 70;

o[1, 1] = 25; o[1, 2] = 30;
A[1] = 3; B[1] = 4;

p1 = 35; p2 = 35;

(*This parameter can be changed, where g[l]>0*)
Table[g[l] = 1000, {l, 1, q}];

(*Function definitions*)
H = 1/2 ((x - p1)^2 + (y - p1)^2);

Table[EO[l] = 1/2 (((x - o[l, 1])/(A[l] + r))^2 + ((y - o[l, 1])/(B[l] + r))^2 - 1),{l, 1, q}];

(*We require the plot of the following function*)
L = H + Sum[g[l]/EO[l], {l, 1, q}];

(*The plot*)
Plot3D[L, {x, 0, xmax}, {y, 0, ymax}, ColorFunction -> "Rainbow", Mesh -> None, PlotStyle -> Directive[Opacity[5]], ClippingStyle -> None]
$\endgroup$

closed as off-topic by Artes, m_goldberg, bbgodfrey, Dr. belisarius, Öskå Mar 12 '15 at 21:36

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Artes, m_goldberg, bbgodfrey, Öskå
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ @Kuba, Thanks. I will include the code. $\endgroup$ – Jack Mar 12 '15 at 11:21
  • $\begingroup$ @Kuba, I have added the code. I was randomly generating the position of the repulsive potential but I have kept it fixed in the code given here. The parameter g[l] is user-defined. The larger it is the greater the repulsive potential. $\endgroup$ – Jack Mar 12 '15 at 12:10
  • $\begingroup$ Use the option PlotPoints in Plot3D. For instance PlotPoints->100 gives a fairly smooth outline of the objects. $\endgroup$ – Dr. Wolfgang Hintze Mar 12 '15 at 12:27
  • $\begingroup$ related: 4244 $\endgroup$ – Kuba Mar 12 '15 at 12:29
  • $\begingroup$ @ Dr. Wolfgang Hintze and @Kuba, Thank you for the help. $\endgroup$ – Jack Mar 13 '15 at 3:02
3
$\begingroup$

The behavior is due to your calculations, specifically the EO[l]-table, inducing a singularity region (i.e.: the EO[l]-table is 0 for the region you see in your plot).

So, the plots are "correct", which you can verify by adding the options PlotRange->All and PlotPoints->250 (or even more).

You will have to fix those singularities (in this case resulting from deleting by zero) to get your desired smooth result.

Proof of the singularity in the E[l]-table

Plot[Evaluate[Table[EO[l],{l,1,q}]/.y->20],{x,0,40},AxesOrigin->{0,0}]

The function constructed by the table has a zero-point

$\endgroup$
  • $\begingroup$ Thank you very much. I have rewritten EO[l] as a piecewise function where I set EO[l] to 1 whenever it is 0. It solved the problem. $\endgroup$ – Jack Mar 12 '15 at 12:33

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