neorobin wrote:Hi einstein1969
I made another implementation, origin from 3D Sphere
viewtopic.php?f=3&t=5594map rule: [0,2pi) to [-pi/2, pi/2]
Code: Select all
angle t in [0,2pi)
0 <= t < pi/2 t -> t in [-pi/2, 0)
not need map
pi/2 <= t < 3pi/2 t -> pi-t in (-pi/2, pi/2]
sin(t) = sin(pi-t), cos(t) = -cos(pi-t)
3pi/2 <= t < 2pi t -> -2pi+t in [-pi/2, 0)
sin(t) = sin(-2pi+t), cos(t) = cos(-2pi+t)
my test code
Code: Select all
@echo off
mode 100
set "SIN=(t-t*t/1875*t/320000+t*t/1875*t/15625*t/16000*t/2560000-t*t/1875*t/15360*t/15625*t/15625*t/16000*t/44800000)"
set "COS=(10000-t*t/20000+t*t/1875*t/15625*t/819200-t*t/1875*t/15360*t/15625*t/15625*t/10240000+t*t/1875*t/15360*t/15625*t/15625*t/16000*t/15625*t/229376000)"
REM 15 test angles in [0, 2Pi) step by Pi/8
set "List=0,3927,7854,11781,15708,19635,23562,27489,31416,35343,39270,43197,47124,51051,54978,58905"
set /a "p=31416, p2=62832, pn2=-62832, p#2=15708, p3#2=47124, p3#2_=p3#2-1"
set R_Sin=
set R_Cos=
for %%a in (%List%) do (
set /a "t=%%a"
set /a "t%%=p2,s1=(t-p#2^t-p3#2)>>31, s3=p3#2_-t>>31, t=(-t&s1)+(t&~s1)+(p&s1)+(pn2&s3), r1=%SIN%"
set /a "t=%COS%, r2=(-t&s1)+(t&~s1)"
setlocal EnableDelayedExpansion
set R_Sin=!R_Sin!!r1!,
set R_Cos=!R_Cos!!r2!,
)
set R_
pause
test result
Code: Select all
R_Cos=10000,9238,7071,3826,0,-3826,-7071,-9238,-10000,-9238,-7071,-3826,0,3826,7071,9238,
R_Sin=0,3827,7071,9239,9999,9239,7071,3827,0,-3827,-7071,-9239,-9999,-9239,-7071,-3827,
Two usage examples: tested on WIN7 64bit and XP 32bit
Please edit the code, replace the ★ to a real TAB character (ASCII 0x9).
spiral
Code: Select all
@echo off & setlocal enabledelayedexpansion
set "TAB=★" & for /F %%a in ('"prompt $h&for %%b in (1) do rem"')do Set "BS=%%a"
set /a "ZM=10000, p=31416, p2=62832, pn2=-62832, p#2=15708, p3#2=47124, p3#2_=p3#2-1, DEG=31416/180"
set "SIN=(t-t*t/1875*t/320000+t*t/1875*t/15625*t/16000*t/2560000-t*t/1875*t/15360*t/15625*t/15625*t/16000*t/44800000)"
set "COS=(10000-t*t/20000+t*t/1875*t/15625*t/819200-t*t/1875*t/15360*t/15625*t/15625*t/10240000+t*t/1875*t/15360*t/15625*t/15625*t/16000*t/15625*t/229376000)"
set /a "wid=75, hei=75, iMax=wid*hei, wid_div_2 = wid / 2 - 3"
color 0c & mode !wid!,!hei!
(for /l %%i in (1 1 !iMax!) do set "scr= !scr!") & set "emp=!scr!"
set /a "buffwid = wid, linesWantBackAbove = hei - 1, cntBS = 2 + (buffwid + 7) / 8 * linesWantBackAbove"
set "BSs=" & for /L %%a in (1 1 !cntBS!) do set "BSs=!BSs!%BS%"
set "aLineBS=" & for /L %%a in (1 1 !wid!) do set "aLineBS=!aLineBS!%BS%"
set /a "XC = wid/2, YC = hei/2, DEG_unit = 3, ddu=1, th0=!random! %% 360 * DEG"
for /L %%i in (5000 -1 0) do (
set /a "th=th0+p2+DEG*%%i, DEG_unit+=ddu, DEG_unit= DEG_unit %% 360"
for /l %%a in (0 1 !wid_div_2!) do (
set /a "th+=p2+DEG * DEG_unit, th %%= p2, th += th>>31&p2, t=th, s1=(t-p#2^t-p3#2)>>31, s3=p3#2_-t>>31, t=(-t&s1)+(t&~s1)+(p&s1)+(pn2&s3), SINt=%SIN%, t=%COS%, COSt=(-t&s1)+(t&~s1)"
set /a "r=%%a, x=(XC*10000 + r * COSt)/10000, y=(YC*10000 + r * SINt)/10000, inScr=(x-0^x-wid)&(y-0^y-hei)"
REM if !inScr! lss 0 (
set /a "ind=x+y*wid+1, lenL=ind-1"
for /f "tokens=1,2" %%a in ("!lenL! !ind!") do (set scr=!scr:~0,%%a!*!scr:~%%b!)
REM )
)
<nul set /p "=!aLineBS!" & (2>nul echo;%TAB%!BSs!) & <nul set /p "=%BS%"
<nul set /p "=%BS%!scr:~0,-1!" & set "scr=!emp!" & title %%i / 5000
)
>nul pause
exit
3D Torus Vortex
Please edit the code, replace the ★ to a real TAB character (ASCII 0x9).
Code: Select all
@echo off & setlocal enabledelayedexpansion & chcp 437 & title 3D Torus Vortex
set "Path=%SystemRoot%\system32" & for /f "delims==" %%a in ('set') do if /i "%%a" neq "Path" set "%%a="
set "SIN=(t-t*t/1875*t/320000+t*t/1875*t/15625*t/16000*t/2560000-t*t/1875*t/15360*t/15625*t/15625*t/16000*t/44800000)"
set "COS=(10000-t*t/20000+t*t/1875*t/15625*t/819200-t*t/1875*t/15360*t/15625*t/15625*t/10240000+t*t/1875*t/15360*t/15625*t/15625*t/16000*t/15625*t/229376000)"
set /a "ZM=10000, p=31416, p2=62832, pn2=-62832, p#2=15708, p3#2=47124, p3#2_=p3#2-1, DEG=31416/180"
set /a "Cols=wid=330, lines=hei=130, lines_plus_1=lines+1"
mode !Cols!,!lines_plus_1!
set "TAB=★" & for /F %%a in ('"prompt $h&for %%b in (1) do rem"')do Set "BS=%%a"
set /a "buffwid = wid, linesWantBackAbove = hei - 1 + 1, cntBS = 2 + (buffwid + 7) / 8 * linesWantBackAbove"
set "BSs=" & for /L %%a in (1 1 !cntBS!) do set "BSs=!BSs!%BS%"
set "aLineBS=" & for /L %%a in (1 1 !wid!) do set "aLineBS=!aLineBS!%BS%"
set "LN0=" & for /L %%C in (1 1 !Cols!) do set "LN0= !LN0!"
for /L %%L in (1 1 !lines!) do set "LN%%L=!LN0!"
set /a "pixel_h=6, pixel_w=4" & rem Fontsize 4X6
rem zscr: screen Z coor, zeye: eye point Z coor
set /a "XC = Cols/2, YC = lines/2, zscr = 128, zeye = 400, zs2e=zscr-zeye"
set /a "R1 = 68, r2 = 60, TH1 = 0, th2 = 0, cntRings=120, cntRings_1=cntRings-1, cntDotPerRing=20, cntDotPerRing_1=cntDotPerRing-1"
set /a "sumDots=cntDotPerRing*cntRings"
set /a "dth2base=(P2+P2/cntRings)/cntDotPerRing, offsClose=p2-(dth2base*cntDotPerRing-p2)*cntRings"
set "offsClose=!offsClose!/!sumDots!"
set /a "dTH1base=p2/cntRings, offsCloseBigCircle=p2-dTH1base*cntRings"
set "offsCloseBigCircle=!offsCloseBigCircle!/!cntRings!"
set /a "Z_cut_ZM=999*ZM" & rem The cutting plane parallel to plane xoy, Cut the front. When this value is large enough, there is no cutting effect
for /l %%i in (0 1 !cntRings_1!) do (
for /l %%j in (0 1 !cntDotPerRing_1!) do (
set /a "TH1=%%i*dTH1base+ %%i * %offsCloseBigCircle%, TH1 %%= p2, TH1 += TH1>>31&p2, t=TH1, s1=(t-p#2^t-p3#2)>>31, s3=p3#2_-t>>31, t=(-t&s1)+(t&~s1)+(p&s1)+(pn2&s3), SIN_TH1=%SIN%, t=%COS%, COS_TH1=(-t&s1)+(t&~s1)"
set /a "t=%%i*cntDotPerRing+%%j,th2=t*dth2base+t*%offsClose%, th2 %%= p2, th2 += th2>>31&p2, t=th2, s1=(t-p#2^t-p3#2)>>31, s3=p3#2_-t>>31, t=(-t&s1)+(t&~s1)+(p&s1)+(pn2&s3), SIN_th2=%SIN%, t=%COS%, COS_th2=(-t&s1)+(t&~s1)"
title 3D Torus Vortex %%i/!cntRings_1! %%j/!cntDotPerRing_1! TH1: !TH1! th2: !th2!
set /a "z_ZM=(R1*ZM + r2*COS_th2)/ZM * SIN_TH1, z_t2eye_ZM=z_ZM -zeye*ZM, x=XC + (R1*ZM + r2*COS_th2)/ZM * COS_TH1 *zs2e* pixel_h /(z_t2eye_ZM * pixel_w), y=YC + r2 * SIN_th2 *zs2e/z_t2eye_ZM, inScr=(x-0^x-wid)&(y-0^y-hei)"
set /a "inner=(th2-p#2^th2-p3#2)" & rem distance to the y-axis < big circle radius
if !z_ZM! LSS !Z_cut_ZM! (
set /a "ind=x+1, lenL=ind-1"
for /f "tokens=1-3" %%a in ("!lenL! !ind! !y!") do (
if !TH1! LSS !p! (
if !inner! LSS 0 ( set "LN%%c=!LN%%c:~0,%%a!#!LN%%c:~%%b!"
) else ( set "LN%%c=!LN%%c:~0,%%a!o!LN%%c:~%%b!"
)
) else (
if !inner! LSS 0 ( rem set "LN%%c=!LN%%c:~0,%%a!*!LN%%c:~%%b!" & Blank the behind half of the inner hole
) else ( set "LN%%c=!LN%%c:~0,%%a!.!LN%%c:~%%b!"
)
)
)
)
<nul set /p "=!aLineBS!" & (2>nul echo;%TAB%!BSs!) & <nul set /p "=%BS%"
for /L %%d in (1 1 !lines!) do <nul set /p "=%BS%!LN%%d!"
)
)
>nul pause
exit