Re: LuaSketch….od almeno ci si prova

#60247
Up
0
Down
::

ansys” post=62136Ad essere belli, sono belli; ma se non si vede il codice servono a poco 🙂 .

Ciao
Orlando

Bé…. se volete vedere il codice, ecco quello della seconda figura:

`
% !TEX encoding = UTF-8
% !TEX program = LuaLaTeX
% !TEX spellcheck = en_GB
\documentclass{report}%standalone}

\usepackage[%showframe,
a4paper,
margin = 1cm]{geometry}

\usepackage{tikz}
\usetikzlibrary{arrows}

\input{ProveSingoleFunzioni_Fun.tex}

\directlua{
require “math”
dofile(“Lua/BasicFunctions.lua”)
dofile(“Lua/CreateObjects.lua”)
dofile(“Lua/3Dfunctions.lua”)
dofile(“Lua/PrintTikZfunctions.lua”)
}

\begin{document}
\centering
\begin{tikzpicture}[line join=round,thick,>=angle 45]
\colorlet{plume}{brown}
\directlua{
eye = {5,-5,5.5}
look_at = {0,0,0}
theta = 0

%%%%%%%%%%%%%%%%%%%%
% REFERENCES AXIS %
%%%%%%%%%%%%%%%%%%%%
refAxisLength = 3
O = {0,0,0}
refX = {refAxisLength,0,0}
refY = {0,refAxisLength,0}
refZ = {0,0,refAxisLength}
refAxis = Group(PointsCurve({O,refX},”->”),
PointsCurve({O,refY},”->”),
PointsCurve({O,refZ},”->”),
Node(refX,”left”,”$x$”),
Node(refY,”right”,”$y$”),
Node(refZ,”above”,”$z$”))

%%%%%%%%%
% TORUS %
%%%%%%%%%
R = 3.2
rr = 1
rz = 3
CenterPoint = {0,0,0}
nU = 100
nV = 10
torus = Torus(R,rr,rz,CenterPoint,nU,nV,”fill=plume,fill opacity=.2″,”half”)

%%%%%%%%%%%%%%%%%%%%%
% CROSSING I xR-rr %
%%%%%%%%%%%%%%%%%%%%%%
xII = R+.5
PIIin = {xII, math.sqrt((R+A)^2-xII^2),z}
PIIout = {xII,-math.sqrt((R+A)^2-xII^2),z}

InnerLeftLaser = PointsCurve({PIIin,PIIout},”red,dashed”)

%%%%%%%%%%%%%%%%%%%%%%%
% INNER CIRCUMFERENCE %
%%%%%%%%%%%%%%%%%%%%%%%
alphaIN = 102.5
alphaINdashed = 360-alphaIN

InnerCircumference = Arc(R-rr,O,alphaIN,alphaIN,””)
InnerCircumference = rotate(InnerCircumference,O,{0,0,1},135-alphaIN/2)

InnerCircumferenceDashed = Arc(R-rr,O,alphaINdashed,alphaINdashed,”dashed”)
InnerCircumferenceDashed = rotate(InnerCircumferenceDashed,O,{0,0,1},135-alphaINdashed/2-180)

%%%%%%%%%%%%%%%%%%%%%%%
% OUTER CIRCUMFERENCE %
%%%%%%%%%%%%%%%%%%%%%%%
alphaOUT = 180
alphaOUTdashed = 360-alphaOUT

OuterCircumference = Arc(R+rr,O,alphaOUT,alphaOUT,””)
OuterCircumference = rotate(OuterCircumference,O,{0,0,1},-135)

OuterCircumferenceDashed = Arc(R+rr,O,alphaOUTdashed,alphaOUTdashed,”dashed”)
OuterCircumferenceDashed = rotate(OuterCircumferenceDashed,O,{0,0,1},45)

%%%%%%%%%%%%%%%%
% RISING PHASE %
%%%%%%%%%%%%%%%%
RisingPhase = Polygon(“fill=green!60!black,fill opacity=.5″,{R-rr,0,0},{R,0,rz},{R-rr,0,rz})

%%%%%%%%%%
% LASERS %
%%%%%%%%%%
yL = -6

%-> Central Laser
PIL1 = {xI,yL,z}
PIL2 = {0,0,z}
PIL3 = {xI,-yL,z}
OuterCentralLaser1 = PointsCurve({PIL1,PIin2},”red,overlay”)
OuterCentralLaser2 = PointsCurve({PIout2,PIL2},”red,overlay”)
OuterCentralLaser3 = PointsCurve({PIL2,PIin1},”red,overlay”)
OuterCentralLaser4 = PointsCurve({PIout1,PIL3},”red,overlay”)

%-> Outer Laser
PIIL = {xII,yL,z}
PIIL2 = {xII,-yL,z}
OuterLeftLaser1 = PointsCurve({PIIL,PIIout},”red,overlay”)
OuterLeftLaser2 = PointsCurve({PIIin,PIIL2},”red,overlay”)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PARTICLES TRAJECTORIES RIGHT %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TrajectoriesLeft = Group()

n = 50

for i=1,4 do
RadiusX = (1-(i-1)/4)*rr
RadiusZ = (1-(i-1)/4)*rz
Radius = R-rr+RadiusX
Xformula = Radius..”+”..RadiusX..”*math.cos(v)”
Zformula = RadiusZ..”*math.sin(v)”

TrajectoriesLeft = ParametricCurve(“v”,Xformula,
“0”,
Zformula,
0,
math.pi,
n,
“<-") end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PARTICLES TRAJECTORIES CENTER % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TrajectoriesRight1 = Group() TrajectoriesRight2 = Group() n = 50 for i=1,4 do RadiusX = (1-(i-1)/4)*rr RadiusZ = (1-(i-1)/4)*rz Radius = R-rr+RadiusX Yformula1 = Radius.."+"..RadiusX.."*math.cos(v)" Yformula2 = "-"..Radius.."+"..RadiusX.."*math.cos(v)" Zformula = RadiusZ.."*math.sin(v)" TrajectoriesRight1[i] = ParametricCurve("v","0", Yformula1, Zformula, 0, math.pi, n, "<-") TrajectoriesRight2[i] = ParametricCurve("v","0", Yformula2, Zformula, 0, math.pi, n, "->“)

end

%%%%%%%%%%%%%%%
% NOZZLE AXIS %
%%%%%%%%%%%%%%%
H = rz+3
hp = .6
nA1 = {0,0,H}
nA2 = {0,0,hp}
nozzleAxis1 = PointsCurve({O,nA2},”loosely dashed”)
nozzleAxis2 = PointsCurve({nA2,nA1},”loosely dashed”)

%%%%%%%%%%
% LABELS %
%%%%%%%%%%
Lcl = Node(PIL3,”red,above,overlay”,”Center laser position”)
Lll = Node(PIIL2,”red,above,overlay”,”Left laser position”)

dl = Special(“\string\\draw[latex-latex] (VAR1)–(VAR2)node[sloped,midway,fill=white]{$d_l$};”,PIL1,PIIL)

CP1 = Special(“\string\\fill[red] (VAR1)circle[radius=.071]”..
“node[anchor=south east]{1};”,PIin2)
CP2 = Special(“\string\\fill[red] (VAR1)circle[radius=.071]”..
“node[anchor=north west]{2};”,PIout2)
CP3 = Special(“\string\\fill[red] (VAR1)circle[radius=.071]”..
“node[anchor=east]{3};”,PIin1)
CP4 = Special(“\string\\fill[red] (VAR1)circle[radius=.071]”..
“node[anchor=north west]{4};”,PIout1)

LP1 = Special(“\string\\fill[red] (VAR1)circle[radius=.071]”..
“node[anchor=north west]{1};”,PIIout)
LP2 = Special(“\string\\fill[red] (VAR1)circle[radius=.071]”..
“node[anchor=north west]{2};”,PIIin)

Lrp = Special(“\string\\draw[line width=.4cm,green!60!black,opacity=.5,overlay] (VAR1)–++(.4,0)node[black,opacity=1,anchor=west,inner xsep=1pt,line width=.5pt]{= Rising phase};”,{R+1,R+.5,rz/2})

Lna = Node(nA1,”above”,”Nozzle axis”)

Labels = Group(Lcl,Lll,dl,CP1,CP2,CP3,CP4,LP1,LP2,Lrp,Lna)

%%%%%%%%%
% SCENA %
%%%%%%%%%
scena = CreateScene(“nozzleAxis1”,
“OuterCentralLaser2”,
“OuterLeftLaser2”,
“OuterCentralLaser4”,
“InnerCentralLaser1”,
“InnerCentralLaser2”,
“InnerLeftLaser”,
“InnerCircumference”,
“InnerCircumferenceDashed”,
“OuterCircumference”,
“OuterCircumferenceDashed”,
“torus”,
“OuterCentralLaser1”,
“OuterLeftLaser1”,
“OuterCentralLaser3”,
“TrajectoriesLeft”,
“TrajectoriesRight1”,
“TrajectoriesRight2”,
“RisingPhase”,
“nozzleAxis2”,
“Labels”
% ,”refAxis”

)

PrintTikZ(eye,look_at,theta,scena)

}
\end{tikzpicture}
\end{document}
`

Con le figure che ho postato speravo di incuriosire qualcuno….

Quando riuscirò a mettere il render al tutto, ovviamente il codice si accorcerebbe un bel po’

Saluti

Michele

Go to top