Advertisement
zephyrtronium

Li

Mar 21st, 2011
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.74 KB | None | 0 0
  1. /*
  2.     Li Apophysis Plugin
  3.     Copyright 2011 Branden Brown, a.k.a. zephyrtronium
  4.  
  5.     This plugin is free software; you can redistribute it and/or modify
  6.     them under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 3 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This plugin is distributed in the hope that they will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this plugin; if not, see <http://www.gnu.org/licenses/>.
  17.  
  18. */
  19.  
  20. typedef struct
  21. {
  22. } Variables;
  23.  
  24. #include "apoplugin.h"
  25.  
  26. APO_PLUGIN("Li");
  27.  
  28. APO_VARIABLES(
  29. );
  30.  
  31. int PluginVarPrepare(Variation* vp)
  32. {
  33.     return TRUE;
  34. }
  35.  
  36. static const double c[64] =
  37. {
  38. 0.5, 0.3333333333333333, 0.25, 0.2, 0.16666666666666666, 0.14285714285714285,
  39. 0.125, 0.1111111111111111, 0.1, 0.09090909090909091, 0.08333333333333333,
  40. 0.07692307692307693, 0.07142857142857142, 0.06666666666666667, 0.0625,
  41. 0.058823529411764705, 0.05555555555555555, 0.05263157894736842, 0.05,
  42. 0.047619047619047616, 0.045454545454545456, 0.043478260869565216,
  43. 0.041666666666666664, 0.04, 0.038461538461538464, 0.037037037037037035,
  44. 0.03571428571428571, 0.034482758620689655, 0.03333333333333333,
  45. 0.03225806451612903, 0.03125, 0.030303030303030304, 0.029411764705882353,
  46. 0.02857142857142857, 0.027777777777777776, 0.02702702702702703,
  47. 0.02631578947368421, 0.02564102564102564, 0.025, 0.024390243902439025,
  48. 0.023809523809523808, 0.023255813953488372, 0.022727272727272728,
  49. 0.022222222222222223, 0.021739130434782608, 0.02127659574468085,
  50. 0.020833333333333332, 0.02040816326530612, 0.02, 0.0196078431372549,
  51. 0.019230769230769232, 0.018867924528301886, 0.018518518518518517,
  52. 0.01818181818181818, 0.017857142857142856, 0.017543859649122806,
  53. 0.017241379310344827, 0.01694915254237288, 0.016666666666666666,
  54. 0.01639344262295082, 0.016129032258064516, 0.015873015873015872, 0.015625
  55. };
  56.  
  57.  
  58. int PluginVarCalc(Variation* vp)
  59. {
  60.     double x, y, sx, sy, tx, ty;
  61.     x = 0.5 * log(sqr(FTy) + sqr(FTx)));
  62.     y = atan2(FTy, FTx);
  63.     sx = tx = x;
  64.     sy = ty = y;
  65.     int k;
  66.  
  67.     for(k = 0; k < 64; k++)
  68.     {
  69.         double ik = c[k];
  70.         double a = (tx * x - ty * y) * ik, b = (tx * y + ty * x) * ik;
  71.         double rx = a * ik, ry = b * ik;
  72.         if (sqr(rx) + sqr(ry) < EPS)
  73.             break;
  74.         tx = a;
  75.         ty = b;
  76.         sx += rx;
  77.         sy += ry;
  78.     }
  79.     FPx += VVAR * (sx + 0.57721566490153286061 + 0.5 * log(sqr(y) + sqr(x)));
  80.     FPy += VVAR * (sy + atan2(y, x));
  81.  
  82.     return TRUE;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement