# source:git/Singular/LIB/surf.lib@1fff4b

spielwiese
Last change on this file since 1fff4b was 1fff4b, checked in by Olaf Bachmann <obachman@…>, 24 years ago
* cosmetical changes git-svn-id: file:///usr/local/Singular/svn/trunk@3050 2c84dea3-7e68-4137-9b89-c4e89433aadc
• Property mode set to `100644`
File size: 3.4 KB
Line
1// \$Id: surf.lib,v 1.2 1999-05-25 14:59:03 obachman Exp \$
2//
3// author : Hans Schoenemann
4//
5///////////////////////////////////////////////////////////////////////////////
6version="\$Id: surf.lib,v 1.2 1999-05-25 14:59:03 obachman Exp \$";
7info="
8LIBRARY: surf.lib    PROCEDURES FOR GRAPHICS WITH SURF
9
10 plot(I);  plots curves and surfaces
11";
12
13///////////////////////////////////////////////////////////////////////////////
14static proc num_of_vars(ideal I)
15{
16  intvec v;
17  int i;
18  poly p;
19  for(i=size(I);i>0;i--)
20  {
21    p=I[i];
22    while(p!=0)
23    {
26    }
27  }
28  return(v);
29}
30
31proc  plot(ideal I)
32"USAGE:   plot(I);  I ideal
33RETURN:
34NOTE:
35EXAMPLE: example plot; shows an example
36"
37{
38  string l="/tmp/surf"+string(system("pid"));
39  def base=basering;
40  intvec v=num_of_vars(I);
41  int i,j,n;
42  for(i=size(v);i>0;i--)
43  {
44    if (v[i]!=0) { n++; }
45  }
46  if (n==0 or n>3)
47  {
48    "Cannot plot equations with", n, "variables";
49    return();
50  }
51  ring r=0,(x,y,z),dp;
52  short=0;
53  map phi=base,0;
54  j=1;
55  for(i=1;i<=size(v);i++)
56  {
57    if (v[i]!=0)
58    {
59      phi[i]=var(j);
60      j++;
61      if(j==4) break;
62    }
63  }
64  ideal I=simplify(phi(I),2);
65  if (ncols(I)==1 and n<=2) // curve
66  {
67    write(":w "+l,"clip=none;");
68      write(l, "width=500; height=500; set_size; do_background=yes; background_red=255; background_green=255; background_blue=255;");
69    write(l,
70    "root_finder=d_chain_bisection;epsilon=0.0000000001;iterations=20000;");
71    write(l, "curve_green=0; curve_blue=0; curve_width=4.5;");
72    write(l,"curve=",I[1],";");
73    write(l,"draw_curve;");
74  }
75  else
76  {
77    if (ncols(I)==1 and n==3) // surface
78    {
79      write(":w "+l,
80      "root_finder=d_chain_bisection;epsilon=0.0000000001;iterations=20000;");
81     write(l, "width=500; height=500; set_size; do_background=yes; background_red=255; background_green=255; background_blue=255;");
82      write(l,"rot_x=0.14; rot_y=-0.3;");
83      write(l,"surface=",I[1],";");
84      write(l,"draw_surface;");
85    }
86    else
87    {
88      "cannot plot",ncols(I),"equations in",n,"variables";
89      return();
90    }
91  }
92//  "calling surf (by Stephan Endrass) for drawing";
93  i=system("sh","surf "+l+" >/dev/null 2&>1");
94  i=system("sh","/bin/rm "+l);
95}
96example
97{ "EXAMPLE:"; echo =2;
98   // ---------  plane curves ------------
99   ring rr0 = 0,(x1,x2),dp;
100
101   ideal I = x1^3 - x2^2;
102   plot(I);
103   ideal J = x1^2-x1-x2^3;
104   plot(J);
105
106   ring rr1 = 0,(x,y,z),dp;
107   ideal I(1) = 2x2-1/2x3 +1-y+1;
108   plot(I(1));
109   ideal I(2) = x3-x-y;
110   plot(I(2));
111
112  //  ---- Singular Logo --------------
113  poly logo = ((x+3)^3 + 2*(x+3)^2 - y^2)*(x^3 - y^2)*((x-3)^3-2*(x-3)^2-y^2);
114  plot(logo);
115
116
117   // --------- implicit curves ------------
118   // implicit curves
119   ideal I(1) = y,-x2;
120   plot(I(1));
121   ideal I(2) = x2,-y2 +4;
122   plot(I(2));
123
124   //the lemniscate
125
126   ideal I(3) = x4+2x2y2 + y4, x2-y2;
127   plot(I(3));
128
129   // a critical part
130   // adjust the plotregion properly to get a good picture
131
132   poly f = (x-y)*(x2+y);
133   plot(f,1);
134   ideal J = jacob(f);
135   J;
137
138   // ----------- surfaces -------------------
139   ideal J(1) = 3xy4 + 2xy2, x5y3 + x + y6,10x2;
140   plot(J(1));
141
142   // Steiner surface
143
144   ideal J(2) = x^2*y^2+x^2*z^2+y^2*z^2-17*x*y*z;
145   plot(J(2));
146
147  plot(x*(x2-y2)+z2);
148
149  // E7
150  plot(x^3-x*y^3+z^2);
151
152  // Whitney umbrella
153  plot(z^2-x^2*y);
154
155  // A1
156  plot(y2-xz);
157
158
159}
160///////////////////////////////////////////////////////////////////////////////
161
162
Note: See TracBrowser for help on using the repository browser.