Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue Sep 13, 2024 · 3 comments

Comments

@cyberdstar
Copy link

`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
Copy link
Contributor

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 0522378.

@cyberdstar
Copy link
Author

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

@jheinen
Copy link
Collaborator

jheinen commented Sep 16, 2024

The problem is fixed in fed7068.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants