Skip to content

Commit aec7c35

Browse files
Add files via upload
1 parent 26c7a4a commit aec7c35

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
@echo off & setlocal enableDelayedExpansion
2+
3+
if "%~1" neq "" goto :%~1
4+
del /f /q signal.txt
5+
6+
set /a "wid=hei=90"
7+
mode %wid%,%hei%
8+
9+
call :macro
10+
11+
set /a "box.x=wid/2,box.y=hei/2,box.s=15,angle=0"
12+
13+
("%0" Controller >"signal.txt" | "%0" main <"signal.txt") & exit
14+
15+
:main
16+
title T - QUIT
17+
for /l %%# in () do (
18+
19+
if defined key set "lastKey=!key!"
20+
set "key=" & set /p "key="
21+
22+
if /i "!key!" == "q" ( set /a "aR+=2"
23+
) else if /i "!key!" == "a" ( set /a "aR-=2"
24+
) else if /i "!key!" == "w" ( set /a "bR+=2"
25+
) else if /i "!key!" == "s" ( set /a "bR-=2"
26+
) else if /i "!key!" == "e" ( set /a "cR+=2"
27+
) else if /i "!key!" == "d" ( set /a "cR-=2"
28+
) else if /i "!key!" == "r" ( set /a "box.s+=1"
29+
) else if /i "!key!" == "f" ( if !box.s! gtr 3 set /a "box.s-=1"
30+
) else if /i "!key!" == "t" ( echo=.>"abort.txt" & exit )
31+
32+
set /a "anglex=(anglex + aR) %% 360",^
33+
"angley=(angley + bR) %% 360",^
34+
"anglez=(anglez + cR) %% 360"
35+
36+
%@box% box.x box.y box.s angleX angleY angleZ
37+
38+
rem echo !$box!
39+
echo %\e%[2J!$box!%\e%[3;3H[Q,A] Angle X:!anglex!; aR:!aR!%\e%[4;3H[W,S] Angle Y:!angley!; bR:!bR!%\e%[5;3H[E,D] Angle Z:!anglez!; cR:!cR!%\e%[6;3H[R,F] Size: !box.s!
40+
)
41+
exit
42+
43+
:Controller
44+
For /l %%C in () do (
45+
if exist "abort.txt" (
46+
del /f /q "abort.txt"
47+
exit
48+
)
49+
for /f "delims=" %%A in ('choice /c:qawsedrft /n') do echo=%%~A
50+
)
51+
exit
52+
53+
54+
:macro
55+
(set \n=^^^
56+
%= This creates an escaped Line Feed - DO NOT ALTER =%
57+
)
58+
59+
(for /f %%a in ('echo prompt $E^| cmd') do set "\e=%%a") & echo=!\e![?25l
60+
61+
set "sin=(a=((x*31416/180)%%62832)+(((x*31416/180)%%62832)>>31&62832), b=(a-15708^a-47124)>>31,a=(-a&b)+(a&~b)+(31416&b)+(-62832&(47123-a>>31)),a-a*a/1875*a/320000+a*a/1875*a/15625*a/16000*a/2560000-a*a/1875*a/15360*a/15625*a/15625*a/16000*a/44800000) "
62+
set "cos=(a=((15708-x*31416/180)%%62832)+(((15708-x*31416/180)%%62832)>>31&62832), b=(a-15708^a-47124)>>31,a=(-a&b)+(a&~b)+(31416&b)+(-62832&(47123-a>>31)),a-a*a/1875*a/320000+a*a/1875*a/15625*a/16000*a/2560000-a*a/1875*a/15360*a/15625*a/15625*a/16000*a/44800000) "
63+
64+
65+
rem %@line% x0 y0 x1 y1 color <rtn> $line
66+
set @line=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-5" %%1 in ("^!args^!") do (%\n%
67+
if "%%~5" neq "" ( set "$line=%\e%[48;5;%%~5m" ) else set "$line=%\e%[48;5;15m"%\n%
68+
set /a "$x0=%%~1, $y0=%%~2, $x1=%%~3, $y1=%%~4, dx=(((%%~3-%%~1)>>31|1)*(%%~3-%%~1)), dy=-($dy=(((%%~4-%%~2)>>31|1)*(%%~4-%%~2))), err=dx+dy, dist=dx, sx=sy=-1"%\n%
69+
if ^^!dx^^! lss ^^!$dy^^! set dist=^^!$dy^^!%\n%
70+
if ^^!$x0^^! lss ^^!$x1^^! set sx=1%\n%
71+
if ^^!$y0^^! lss ^^!$y1^^! set sy=1%\n%
72+
for /l %%i in (0,1,^^!dist^^!) do (%\n%
73+
set "$line=^!$line^!%\e%[^!$y0^!;^!$x0^!H "%\n%
74+
set /a "e2=2 * err"%\n%
75+
if ^^!e2^^! geq ^^!dy^^! set /a "err+=dy, $x0+=sx"%\n%
76+
if ^^!e2^^! leq ^^!dx^^! set /a "err+=dx, $y0+=sy"%\n%
77+
)%\n%
78+
set "$line=^!$line^!%\e%[0m"%\n%
79+
)) else set args=
80+
81+
82+
:_box
83+
rem predefine points of %@box%
84+
set "points=0" & for %%i in ("-1 -1 -1" " 1 -1 -1" " 1 1 -1" "-1 1 -1" "-1 -1 1" " 1 -1 1" " 1 1 1" "-1 1 1") do (
85+
for /f "tokens=1-3" %%x in ("%%~i") do set /a "x!points!=%%~x, y!points!=%%~y, z!points!=%%~z"
86+
set /a "points+=1"
87+
)
88+
set "points="
89+
rem in=>x y z ; out=>$a $b
90+
set "boxFormula(x,y,z)=rx= x * coa/10000 + z * sia/10000, rz= x * -sia/10000 + z * coa/10000, ry= y * cob/10000 + rz * -sib/10000, $a=rx * coc/10000 + ry * -sic/10000, $b=rx * sic/10000 + ry * coc/10000"
91+
set @box=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-6" %%A in ("^!args^!") do (%\n%
92+
set "$box="%\n%
93+
set /a "coa=^!cos:x=%%~D^!, sia=^!sin:x=%%~D^!, cob=^!cos:x=%%~E^!, sib=^!sin:x=%%~E^!, coc=^!cos:x=%%~F^!, sic=^!sin:x=%%~F^!"%\n%
94+
for /l %%i in (0,1,7) do set /a "x=x%%i * %%~C, y=y%%i * %%~C, z=z%%i * %%~C", "%boxFormula(x,y,z)%", "px[%%i]=$a + %%~A, py[%%i]=$b + %%~B"%\n%
95+
for /l %%i in (0,1,3) do ( set /a "i1=%%i, i2=(%%i + 1) %% 4, j1=i1 + 1, i3=%%i+4, i4=((%%i + 1) %% 4) + 4, j2=j1 + 5, i5=%%i + 4, j3=j2 + 5"%\n%
96+
for /f "tokens=1-6" %%1 in ("^!i1^! ^!i2^! ^!i3^! ^!i4^! ^!i5^!") do (%\n%
97+
^!@line^! ^^!px[%%1]^^! ^^!py[%%1]^^! ^^!px[%%2]^^! ^^!py[%%2]^^! ^^!j1^^!%\n%
98+
set "$box=^!$box^!^!$line^!"%\n%
99+
^!@line^! ^^!px[%%3]^^! ^^!py[%%3]^^! ^^!px[%%4]^^! ^^!py[%%4]^^! ^^!j2^^!%\n%
100+
set "$box=^!$box^!^!$line^!"%\n%
101+
^!@line^! ^^!px[%%1]^^! ^^!py[%%1]^^! ^^!px[%%5]^^! ^^!py[%%5]^^! ^^!j3^^!%\n%
102+
set "$box=^!$box^!^!$line^!"%\n%
103+
)%\n%
104+
)%\n%
105+
)) else set args=
106+
set "boxFormula(x,y,z)="
107+
goto :eof

0 commit comments

Comments
 (0)