From 551965f758b7c10be57a88d90141b729df720603 Mon Sep 17 00:00:00 2001 From: Miguel Lopez Date: Tue, 1 Sep 2020 17:22:16 -0400 Subject: [PATCH] Faster filter by simplifying cos(ang), and sin(ang) --- include/reptorian.gmic | 48 +++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/include/reptorian.gmic b/include/reptorian.gmic index d105d8fc..83478601 100644 --- a/include/reptorian.gmic +++ b/include/reptorian.gmic @@ -64,11 +64,11 @@ rep_pfrac: rep_popcorn_fractal $* rep_popcorn_fractal: skip ${1=50},${2=1},${3=.05},${4=3},${5=1},${6=0},${7=0},${8=0},${9=0},${10=},${11=},${12=},${13=},${14=},${15=} if ($6-360*floor($6/360))?1 - fvx="((rot_x(xnew,ynew)-origin_x*sx)*cx/zoom+cx*sx)/sx" - fvy="((rot_y(xnew,ynew)-origin_y*sy)*cy/zoom+cy*sy)/sy" + fvx="((rot_x(xnew,ynew)-osx)*cx_zoom+cxsx)/sx" + fvy="((rot_y(xnew,ynew)-osy)*cy_zoom+cysy)/sy" else - fvx="((xnew-origin_x*sx)*cx/zoom+cx*sx)/sx" - fvy="((ynew-origin_y*sy)*cy/zoom+cy*sy)/sy" + fvx="((xnew-osx)*cx_zoom+cxsx)/sx" + fvy="((ynew-osy)*cy_zoom+cysy)/sy" fi channels. 0 f. 0 l. @@ -86,12 +86,18 @@ l. const sy=w>h?1:sd; const cx=w/2; const cy=h/2; - const ocx=origin_x*cx; - const ocy=origin_y*cy; + const osx=origin_x*sx; + const osy=origin_y*sy; + const cx_zoom=cx/zoom; + const cy_zoom=cy/zoom; + const cxsx=cx*sx; + const cysy=cy*sy; + const cos_ang=cos(ang); + const sin_ang=sin(ang); const angcondition=($6-360*floor($6/360))?1; const total_pts=wh*pts; - rot_x(a,b)=a*cos(ang)-b*sin(ang); - rot_y(a,b)=a*sin(ang)+b*cos(ang); + rot_x(a,b)=a*cos_ang-b*sin_ang; + rot_y(a,b)=a*sin_ang+b*cos_ang; fvx()="$fvx"; fvy()="$fvy"; count=0; @@ -3591,8 +3597,10 @@ f "begin( const offy=-.5+($16*-1/2); const nw=abs(w*sin(ang))+abs(h*cos(ang)); const nh=abs(w*cos(ang))+abs(h*sin(ang)); - rot_x(a,b)=a*cos(ang)-b*sin(ang); - rot_y(a,b)=a*sin(ang)+b*cos(ang); + const cos_ang=cos(ang); + const sin_ang=sin(ang); + rot_x(a,b)=a*cos_ang-b*sin_ang; + rot_y(a,b)=a*sin_ang+b*cos_ang; const interpolation=abs($18)>2?2:abs($18); const boundary=abs($17); ); @@ -3823,10 +3831,14 @@ repeat $! l[$>] const ang=pi*($8/180); const dang=pi*($12/180); const distrad=1*10^($2/10); - rot_x(a,b)=a*cos(ang)-b*sin(ang); - rot_y(a,b)=a*sin(ang)+b*cos(ang); - dist_rot_x(a,b)=a*cos(dang)-b*sin(dang); - dist_rot_y(a,b)=a*sin(dang)+b*cos(dang); + const cos_ang=cos(ang); + const sin_ang=sin(ang); + const cos_dang=cos(dang); + const sin_dang=sin(dang); + rot_x(a,b)=a*cos_ang-b*sin_ang; + rot_y(a,b)=a*sin_ang+b*cos_ang; + dist_rot_x(a,b)=a*cos_dang-b*sin_dang; + dist_rot_y(a,b)=a*sin_dang+b*cos_dang; sq2(a,b)=sqrt(a^2+b^2); const sd=max(w,h)/min(w,h); const sx=w>h?sd:1; @@ -4085,8 +4097,10 @@ skip ${2=0},${3=0},${4=0} f " begin( ang=pi*($4/180); -rot_x(a,b)=a*cos(ang)-b*sin(ang); -rot_y(a,b)=a*sin(ang)+b*cos(ang); +const cos_ang=cos(ang); +const sin_ang=sin(ang); +rot_x(a,b)=a*cos_ang-b*sin_ang; +rot_y(a,b)=a*sin_ang+b*cos_ang; const blur=(round(abs($2)+1)-1)*2+3; const qblur=sqr(blur); const eblur=floor(blur/2); @@ -8424,7 +8438,7 @@ gui_split_preview "gui_rep_acb $*",${-3--1} #@gui :_=separator() #@gui :_=note("Fractal Calculation Constraints") #@gui :_=note("Information at bottom of filter. Some predefined formulas requires you to use low values. You may need to type in values from 5-1024 manually.") -#@gui :Escape Value=int(10000,5,1000000) +#@gui :Escape Value=int(10000,5,3000000) #@gui :Loop Limitation=int(255,1,1024) #@gui :Subsampling Level=float(3,1,10) #@gui :_=separator(), _=note("Distortion Factors")