home *** CD-ROM | disk | FTP | other *** search
/ Rat's Nest 1 / ratsnest1.iso / prgmming / c / vandrpol.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-19  |  4.1 KB  |  103 lines

  1. Path: unixg.ubc.ca!vanbc.wimsey.com!cyber2.cyberstore.ca!math.ohio-state.edu!howland.reston.ans.net!paladin.american.edu!auvm!C53000.PETROBRAS.ANRJ.BR!BJ06
  2.  
  3. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  4.  
  5. Newsgroups: bit.listserv.frac-l
  6.  
  7. Return-Path: <@AUVM.AMERICAN.EDU,@VTBIT.CC.VT.EDU:FRAC-L@GITVM1.BITNET>
  8.  
  9. X-Envelope-to: FRAC-L@GITVM1.BITNET
  10.  
  11. X-VMS-To: @FRACTAL
  12.  
  13. References: ANSP network   HEPnet SPAN Bitnet Internet gateway
  14.  
  15. Message-ID: <35C294C680001660@fpsp.fapesp.br>
  16.  
  17. Date: Mon, 10 Jan 1994 11:38:00 BDB
  18.  
  19. Sender: "\"FRACTAL\" discussion list" <FRAC-L@GITVM1.BITNET>
  20.  
  21. Comments: @FPSP.FAPESP.BR - @FPSP.HEPNET - @BRFAPESP.BITNET - .BR gateway
  22.  
  23. From: BJ06@C53000.PETROBRAS.ANRJ.BR
  24.  
  25. Subject: VANDRPOL.CPP
  26.  
  27. Lines: 84
  28.  
  29.  
  30.  
  31. //
  32.  
  33. //+------------------------------------------------------------+
  34.  
  35. //+ Program VANDRPOL.CPP                                       +
  36.  
  37. //+ Plots isoclines of the Van Der Pol's ODE (VDP Oscillator): +
  38.  
  39. //+                y" - Mu*y'*(1 - y^2) + y = 0                +
  40.  
  41. //+ or                                                         +
  42.  
  43. //+                v(dv/dy) - Mu*v*(1 - y^2) + y = 0           +
  44.  
  45. //+ Isoclines are defined by (dv/dy) = k                       +
  46.  
  47. //+------------------------------------------------------------+
  48.  
  49. //+ KREYSZIG, E. - _Advanced Engineering Mathematics_ ,        +
  50.  
  51. //+                John Wiley & Sons, 1988, pp. 165-166        +
  52.  
  53. //+ Requires SVGA and SVGA256.BGI + SVGA256.H                  +
  54.  
  55. //+------------------------------------------------------------+
  56.  
  57. //+ Usage:                                                     +
  58.  
  59. //+      VANDRPOL <Mu> <ymin> <ymax> <vmin> <vmax>             +
  60.  
  61. //+ Example:                                                   +
  62.  
  63. //+      VANDRPOL 0.32 -5.0 5.0 -5.0 5.0                       +
  64.  
  65. //+ Try:                                                       +
  66.  
  67. //+      Mu     xmin     xmax     ymin     ymax                +
  68.  
  69. //+     0.1     -5.0      5.0     -5.0      5.0                +
  70.  
  71. //+   -3.95     -4.0      4.0     -4.0      4.0                +
  72.  
  73. //+    0.05     -5.0      5.0     -5.0      5.0                +
  74.  
  75. //+   -0.75     -5.0      5.0     -5.0      5.0                +
  76.  
  77. //+    8.75     -5.0      5.0     -5.0      5.0                +
  78.  
  79. //+------------------------------------------------------------+
  80.  
  81. //+ COMMENTS modified by N. Giffin at Fausto's request. May/94 +
  82.  
  83. //+------------------------------------------------------------+
  84.  
  85. //+ By Fausto A. A. Barbuto, January 8, 1994                   +
  86.  
  87. //+ [PS: This is probably NOT a fractal, but it's              +
  88.  
  89. //+      good-looking! :-)  ]                                  +
  90.  
  91. //+------------------------------------------------------------+
  92.  
  93. //
  94.  
  95. #include <stdio.h>
  96.  
  97. #include <conio.h>
  98.  
  99. #include <graphics.h>
  100.  
  101. #include <math.h>
  102.  
  103. #include <stdlib.h>
  104.  
  105. #include "Svga256.h"
  106.  
  107.  
  108.  
  109. //void far initgraph(int far *,int far *,char far *);
  110.  
  111.  
  112.  
  113. int huge DetectVGA256()
  114.  
  115. {
  116.  
  117.   int Vid=4;
  118.  
  119.   return Vid;
  120.  
  121. }
  122.  
  123.  
  124.  
  125. void main(int argc, char *argv[])
  126.  
  127. {
  128.  
  129.       double Mu, ymin, ymax, vmin, vmax;
  130.  
  131.       double y, v, k, const_scr=1.0, deltav, deltay;
  132.  
  133.       register int npix=1024, npiy=768;
  134.  
  135.       register int ny, nv, ipen;
  136.  
  137.       char *endptr;
  138.  
  139.       int graphdriver=DETECT;
  140.  
  141.       int graphmode;
  142.  
  143.  
  144.  
  145.       Mu = strtod(argv[1],&endptr);
  146.  
  147.       ymin = strtod(argv[2],&endptr);
  148.  
  149.       ymax = strtod(argv[3],&endptr);
  150.  
  151.       vmin = strtod(argv[4],&endptr);
  152.  
  153.       vmax = strtod(argv[5],&endptr);
  154.  
  155.  
  156.  
  157.       installuserdriver("Svga256",DetectVGA256);
  158.  
  159.       initgraph(&graphdriver, &graphmode, "c:\\borlandc\\bgi");
  160.  
  161.  
  162.  
  163.       deltay = (ymax-ymin)/(double)npix;
  164.  
  165.       deltav = (vmax-vmin)/(double)npiy;
  166.  
  167.  
  168.  
  169.       cleardevice();
  170.  
  171.       for (ny=0; ny<=npix-1; ny++) {
  172.  
  173.         y = ymin + (double)ny*deltay;
  174.  
  175.         for (k=-5.0; k<=5.0; k=k+0.025) {
  176.  
  177.           v = y/(Mu*(1.0-y*y) - k);
  178.  
  179.           nv = (int)((v - vmin)/deltav);
  180.  
  181.           ipen = 33 + (int)(1.5*(k+5.0));
  182.  
  183.           putpixel(ny,nv,ipen);
  184.  
  185.         }
  186.  
  187.      }
  188.  
  189.  
  190.  
  191. // Clean-up.
  192.  
  193. // Fecha a parte grafica.
  194.  
  195.  
  196.  
  197.       getch();
  198.  
  199.       closegraph();
  200.  
  201.       restorecrtmode();
  202.  
  203. }
  204.  
  205.