Rev 328 | Rev 439 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
259 | daniel-mar | 1 | /* |
2 | This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop |
||
3 | Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.com.au |
||
4 | Copyright (C) 2018-2021 Daniel Marschall, ViaThinkSoft |
||
5 | |||
6 | This program is free software; you can redistribute it and/or modify |
||
7 | it under the terms of the GNU General Public License as published by |
||
8 | the Free Software Foundation; either version 2 of the License, or |
||
9 | (at your option) any later version. |
||
10 | |||
11 | This program is distributed in the hope that it will be useful, |
||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
14 | GNU General Public License for more details. |
||
15 | |||
16 | You should have received a copy of the GNU General Public License |
||
17 | along with this program; if not, write to the Free Software |
||
18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
19 | */ |
||
20 | |||
21 | #include <math.h> |
||
22 | |||
335 | daniel-mar | 23 | // Strict compatibility to Filter Factory by using an alternative |
24 | // implementation which is a 100% replica of the Filter Factory 3.0.4 |
||
25 | // for Windows. |
||
26 | #ifdef WIN_ENV |
||
27 | // i,u,v intentionally not equal to Filter Factory (this has been documented). |
||
28 | //#define use_filterfactory_implementation_i |
||
29 | //#define use_filterfactory_implementation_u |
||
30 | //#define use_filterfactory_implementation_v |
||
31 | // umin,umax and vmin,vmax intentionally not equal to Filter Factory (this has been documented). |
||
32 | //#define use_filterfactory_implementation_u_minmax |
||
33 | //#define use_filterfactory_implementation_v_minmax |
||
34 | // U and V intentionally not equal to Filter Factory (this has been documented). |
||
35 | //#define use_filterfactory_implementation_U |
||
36 | //#define use_filterfactory_implementation_V |
||
37 | // dmin,dmax intentionally not equal to Filter Factory (this has been documented). |
||
38 | //#define use_filterfactory_implementation_d_minmax |
||
39 | // D intentionally not equal to Filter Factory (this has been documented). |
||
40 | //#define use_filterfactory_implementation_D |
||
41 | // get(i) intentionally not equal to Filter Factory (this has been documented). |
||
42 | //#define use_filterfactory_implementation_get |
||
43 | // Following functions are implemented as 100% replicas |
||
44 | #define use_filterfactory_implementation_rad |
||
45 | #define use_filterfactory_implementation_rnd |
||
46 | #define use_filterfactory_implementation_c2d |
||
47 | #define use_filterfactory_implementation_c2m |
||
48 | #define use_filterfactory_implementation_r2x |
||
49 | #define use_filterfactory_implementation_r2y |
||
50 | #define use_filterfactory_implementation_cos |
||
51 | #define use_filterfactory_implementation_sin |
||
52 | #define use_filterfactory_implementation_tan |
||
53 | #define use_filterfactory_implementation_sqr |
||
54 | #define use_filterfactory_implementation_d |
||
55 | #define use_filterfactory_implementation_m |
||
56 | #define use_filterfactory_implementation_M |
||
57 | #endif |
||
259 | daniel-mar | 58 | |
335 | daniel-mar | 59 | |
259 | daniel-mar | 60 | #ifndef M_PI |
268 | daniel-mar | 61 | #define M_PI 3.14159265358979323846264338327 |
259 | daniel-mar | 62 | #endif |
63 | |||
64 | |||
65 | #include "symtab.h" |
||
66 | |||
67 | enum{ COSTABSIZE=1024,TANTABSIZE=512 }; |
||
68 | |||
69 | void init_trigtab(); |
||
70 | |||
71 | extern double costab[],tantab[]; |
||
72 | |||
73 | #define DEG2RAD(x) ((x)*M_PI/180.) |
||
74 | #define RAD2DEG(x) ((x)*180./M_PI) |
||
75 | |||
76 | /* [trig functions return] an integer between -512 and 512, inclusive (Windows) |
||
77 | or -1024 and 1024, inclusive (Mac OS) */ |
||
78 | #ifdef WIN_ENV |
||
79 | #define TRIGAMP 512 |
||
80 | #else |
||
81 | #define TRIGAMP 1024 |
||
82 | #endif |
||
83 | #define FFANGLE(v) ((v)*M_PI/512.) |
||
84 | #define TO_FFANGLE(v) ((v)*512./M_PI) |
||
85 | |||
294 | daniel-mar | 86 | #define INITRANDSEED() initialize_rnd_variables() |
87 | void initialize_rnd_variables(); |
||
259 | daniel-mar | 88 | |
294 | daniel-mar | 89 | // Functions |
259 | daniel-mar | 90 | value_type ff_src(value_type x,value_type y,value_type z); |
91 | value_type ff_rad(value_type d,value_type m,value_type z); |
||
92 | value_type ff_ctl(value_type i); |
||
93 | value_type ff_val(value_type i,value_type a,value_type b); |
||
94 | value_type ff_map(value_type i,value_type n); |
||
95 | value_type ff_min(value_type a,value_type b); |
||
96 | value_type ff_max(value_type a,value_type b); |
||
97 | value_type ff_abs(value_type a); |
||
98 | value_type ff_add(value_type a,value_type b,value_type c); |
||
99 | value_type ff_sub(value_type a,value_type b,value_type c); |
||
100 | value_type ff_dif(value_type a,value_type b); |
||
101 | value_type ff_rnd(value_type a,value_type b); |
||
102 | value_type ff_mix(value_type a,value_type b,value_type n,value_type d); |
||
103 | value_type ff_scl(value_type a,value_type il,value_type ih, |
||
104 | value_type ol,value_type oh); |
||
105 | value_type ff_sqr(value_type x); |
||
106 | value_type ff_sin(value_type x); |
||
107 | value_type ff_cos(value_type x); |
||
108 | value_type ff_tan(value_type x); |
||
109 | value_type ff_r2x(value_type d,value_type m); |
||
110 | value_type ff_r2y(value_type d,value_type m); |
||
294 | daniel-mar | 111 | value_type ff_c2d(value_type d,value_type m); |
259 | daniel-mar | 112 | value_type ff_c2m(value_type d,value_type m); |
113 | value_type ff_get(value_type i); |
||
114 | value_type ff_put(value_type v,value_type i); |
||
115 | value_type ff_cnv(value_type m11,value_type m12,value_type m13, |
||
116 | value_type m21,value_type m22,value_type m23, |
||
117 | value_type m31,value_type m32,value_type m33, |
||
118 | value_type d ); |
||
119 | value_type ff_rst(value_type seed); |
||
294 | daniel-mar | 120 | |
121 | // Variables |
||
122 | value_type ff_i(); |
||
123 | value_type ff_u(); |
||
124 | value_type ff_v(); |
||
125 | value_type ff_D(); |
||
126 | value_type ff_d(); |
||
127 | value_type ff_M(); |
||
128 | value_type ff_m(); |
||
304 | daniel-mar | 129 | |
335 | daniel-mar | 130 | extern value_type min_val_i; |
131 | extern value_type max_val_i; |
||
132 | extern value_type min_val_u; |
||
133 | extern value_type max_val_u; |
||
134 | extern value_type min_val_v; |
||
135 | extern value_type max_val_v; |
||
136 | extern value_type min_val_d; |
||
137 | extern value_type max_val_d; |
||
138 | extern value_type val_D; |
||
139 | extern value_type val_I; |
||
140 | extern value_type val_U; |
||
141 | extern value_type val_V; |