sciapp / gr

GR framework: a graphics library for visualisation applications
Other
328 stars 55 forks source link

i rewrite c code form python “Simple surface plot example”,the result do not like in python example,how to correct this? #191

Open cyberdstar opened 2 months ago

cyberdstar commented 2 months ago

`static int const lenll = 29; static int const lenll2 = lenll lenll; double xx[lenll], yy[lenll], xy[lenll2]; for (int i = 0; i < lenll; i++) { xx[i] = -2 + i 0.5; yy[i] = -7 + i 0.5; } for (int i = 0; i < lenll; i++) { for (int j = 0; j < lenll; j++) { double r1 = sqrt(pow(xx[j] - 5, 2) + yy[i] yy[i]); double r2 = sqrt(pow(xx[j] + 5, 2) + yy[i] yy[i]); xy[i lenll + j] = (exp(cos(r1)) + exp(cos(r2)) - 0.9) * 25; } } gr_setcharheight(24.0 / 500); gr_settextalign(GKS_K_TEXT_HALIGN_CENTER, GKS_K_TEXT_VALIGN_TOP); char title[] = "Surface Example"; gr_textext(0.5, 0.9, title); double tbx[32], tby[32]; gr_inqtextext(0.5, 0.9, title, tbx, tby); //gr_setlinetype(0); //gr_setfillintstyle(0); gr_fillarea(4,tbx, tby);

gr_setwindow(-2, 12, -7, 7); gr_setspace(-80, 200, 45, 70);

gr_setcharheight(14.0 / 500); gr_axes3d(1, 0, 20, -2, -7, -80, 2, 0, 2, -0.01); gr_axes3d(0, 1, 0, 12, -7, -80, 0, 2, 0, 0.01); gr_titles3d("X-Axis", "Y-Axis", "Z-Axis");

gr_surface(lenll, lenll,xx, yy, xy, 3); gr_surface(lenll, lenll, xx, yy, xy, 1);

gr_updatews();

`

danielkaiser commented 2 months ago

Hi @cyberdstar, your code looks all right, but apparently something has changed in the behavior of gr_surface. I need to investigate further what exactly causes this. For now, however, the code above should work with GR version 0.72.11 as the changed behavior was introduced with 052237889f48c9d5e046fb3f0119895a59cceade.

cyberdstar commented 2 months ago

thanks,this code indeed work with [GR version 0.72.11]

jheinen commented 2 months ago

The problem is fixed in fed7068.