# source:git/Singular/LIB/surf.lib@7e1114d

spielwiese
Last change on this file since 7e1114d was 7e1114d, checked in by Olaf Bachmann <obachman@…>, 24 years ago
• Property mode set to `100644`
File size: 3.1 KB
Line
1// \$Id: surf.lib,v 1.1 1999-05-01 15:27:13 obachman Exp \$
2//
3// author : Hans Schoenemann
4//
5///////////////////////////////////////////////////////////////////////////////
6version="\$Id: surf.lib,v 1.1 1999-05-01 15:27:13 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,
69    "root_finder=d_chain_bisection;epsilon=0.0000000001;iterations=20000;");
70    write(l,"curve=",I[1],";");
71    write(l,"draw_curve;");
72  }
73  else
74  {
75    if (ncols(I)==1 and n==3) // surface
76    {
77      write(":w "+l,
78      "root_finder=d_chain_bisection;epsilon=0.0000000001;iterations=20000;");
79      write(l,"rot_x=0.14; rot_y=-0.3;");
80      write(l,"surface=",I[1],";");
81      write(l,"draw_surface;");
82    }
83    else
84    {
85      "cannot plot",ncols(I),"equations in",n,"variables";
86      return();
87    }
88  }
89//  "calling surf (by Stephan Endrass) for drawing";
90  i=system("sh","surf "+l+" >/dev/null 2&>1");
91  i=system("sh","/bin/rm "+l);
92}
93example
94{ "EXAMPLE:"; echo =2;
95   // ---------  plane curves ------------
96   ring rr0 = 0,(x1,x2),dp;
97
98   ideal I = x1^3 - x2^2;
99   plot(I);
100   ideal J = x1^2-x1-x2^3;
101   plot(J);
102
103   ring rr1 = 0,(x,y,z),dp;
104   ideal I(1) = 2x2-1/2x3 +1-y+1;
105   plot(I(1));
106   ideal I(2) = x3-x-y;
107   plot(I(2));
108
109  //  ---- Singular Logo --------------
110  poly logo = ((x+3)^3 + 2*(x+3)^2 - y^2)*(x^3 - y^2)*((x-3)^3-2*(x-3)^2-y^2);
111  plot(logo);
112
113
114   // --------- implicit curves ------------
115   // implicit curves
116   ideal I(1) = y,-x2;
117   plot(I(1));
118   ideal I(2) = x2,-y2 +4;
119   plot(I(2));
120
121   //the lemniscate
122
123   ideal I(3) = x4+2x2y2 + y4, x2-y2;
124   plot(I(3));
125
126   // a critical part
127   // adjust the plotregion properly to get a good picture
128
129   poly f = (x-y)*(x2+y);
130   plot(f,1);
131   ideal J = jacob(f);
132   J;
134
135   // ----------- surfaces -------------------
136   ideal J(1) = 3xy4 + 2xy2, x5y3 + x + y6,10x2;
137   plot(J(1));
138
139   // Steiner surface
140
141   ideal J(2) = x^2*y^2+x^2*z^2+y^2*z^2-17*x*y*z;
142   plot(J(2));
143
144  plot(x*(x2-y2)+z2);
145
146  // E7
147  plot(x^3-x*y^3+z^2);
148
149  // Whitney umbrella
150  plot(z^2-x^2*y);
151
152  // A1
153  plot(y2-xz);
154
155
156}
157///////////////////////////////////////////////////////////////////////////////
158
159
Note: See TracBrowser for help on using the repository browser.