Notes/Prog/3_charts

0_blog 1_math 2_ps 3_charts 4_rb 5_bash 7_js 9_cook

Osetrin's chart in PS


%!PS
%%BoundingBox: 0 0 400 400

/m { moveto } def
/l { lineto } def
/rl { rlineto } def		% relative lineto
/Rm { rmoveto } def		% relative moveto
/lw { setlinewidth } def
/S { stroke } def
/z { closepath } def
/f { fill } def
/d { setdash } def
/c { curveto } def
/rg { setrgbcolor } def
/12pt {findfont 13 scalefont setfont} def
/7pt {findfont 8 scalefont setfont} def
/q { gsave } def
/Q { grestore } def



1.5 lw
50 5 m 50 380 l S			% axe Y
5 50 m 380 50 l S			% axe X
1 lw
50 389 m -2 -20 rl 2 2 rl 2 -2 rl z f S 	% rule Y
389 50 m -20 -2 rl 2 2 rl -2 2 rl z f S 	% rule X

100 300 2.5 0 360 arc f S 	% observer
190 210 2.5 0 360 arc f S 	% charge
0 0 1 rg
100 45 m 100 370 l S		% observer vert line
0 0 0 rg
[15 10] 0 d					% dased lines:
190 45 m 190 210 l S		% charge vert line
45 300 m 100 300 l S		% observer horis line
45 210 m 190 210 l S		% charge horis line
[20 10] 0 d
50 50 m 250 250 rl S		% light cone (right)
50 50 m -40 40 rl S
[] 0 d
0 0.5 0 rg					% green curve
1.5 lw
190 210 m 190 210   181 210   190 219   181 219  c 
          181 219   172 219   181 228   172 228  c 
          172 228   163 228   172 237   163 237  c 
          163 228   154 237   163 246   154 246  c 
          154 228   145 246   154 255   145 255  c 
          145 228   136 255   145 264   136 264  c 
          136 228   127 264   136 273   127 273  c 
          127 228   118 273   127 282   118 282  c 
          118 228   109 282   118 291   109 291  c 
          109 228   100 291   109 300   100 300  c S
0 0 1 rg
160 140 m 160 140   190 185   190 210 c
          190 210   200 285   240 275   240 360 c S
0 0 0 rg

/Arial 12pt
350 60  m (Space) show
45 rotate 320 -14  m (Light cone) show
40 rotate 330 -222  m (Charge) show
-35 rotate 330 50  m (Photon) show
1 lw
326 54 m 294 54 l S
40  rotate 310 -95  m (Observer) show
		   360 -68  m (Time) show
-90 rotate

/Symbol 12pt 33 373 m (t) show
/Arial 12pt q 370 30 m (x) show	% q - save font size 12pt
/Arial 7pt 0 6 Rm (k) show 

Q 190 30 m (x) show				% Q - restore font size 12pt
/Arial 7pt  0 6 Rm (k) show 
/Symbol 12pt 203 30 m (\() show
 208 30 m (t) show				% tau
 218 30 m (\)) show
/Arial 7pt  213 28 m (1) show

/Symbol 12pt q 30 207 m (t) show
/Arial 7pt 36 205 m (1) show
Q 30 297 m (t) show
/Arial 7pt 36 295 m (2) show
 

Osetrin's chart via ruby → SVG


puts "<style> *{margin:0}"
puts "html {background: url(space1.jpg)  center no-repeat;        background-size: cover;}"
puts "body {background: rgba(255,255,255,0.3)}"
puts "#chart {background: #fff; width: 1000px; height: 95%; margin: 1% 2%; fill: none; stroke-width: 1; border: 1px solid}"
puts "text {font: 22px Serif; fill: black; stroke: none}"
puts "</style>"

AxeColor="#000"
AxeWidth=2
AxeYstartX=200
AxeYstartY=900
AxeYstopY=100
AxeXstartX=100
AxeXstopX=900
AxeXstartY=800
DashedLineColor="#000"
puts "<style>"
puts ".lightcone{stroke-dasharray: 30 20; stroke: #{DashedLineColor}; stroke-width: 1}"
puts ".dashedlines{stroke-dasharray: 20 19; stroke: #{DashedLineColor}; stroke-width: 1}"
puts ".axe{stroke: #{AxeColor}; stroke-width: #{AxeWidth}}"
puts ".rule{stroke-width: 0; fill: #{AxeColor}}"
puts "</style>"

puts "<svg id=chart>"
puts "<polyline points='#{AxeYstartX},#{AxeYstartY} #{AxeYstartX},#{AxeYstopY}' class='axe'/>	<!-- Y axe -->"
puts "<polyline points='#{AxeXstartX},#{AxeXstartY} #{AxeXstopX},#{AxeXstartY}' class='axe'/>	<!-- X axe -->"
puts "<polyline points='#{AxeYstartX},#{AxeXstartY} #{AxeYstartX+500},#{AxeXstartY-500}' class='lightcone'/>			<!-- light cone right side -->"
puts "<polyline points='#{AxeYstartX},#{AxeXstartY} #{AxeYstartX-100},#{AxeXstartY-100}' class='lightcone'/>			<!-- light cone left side -->"
def rule(x,y,a)
	puts "<path d='M #{x},#{y} l -30,4 s 5,-4 0,-8 z' class='rule' transform='rotate(#{a} #{x},#{y})' />"	# x,y - end of rule, a - rotation angle
end
rule(AxeYstartX,AxeYstopY-20,-90)	# Y rule --> 
rule(AxeXstopX+20,AxeXstartY,0)		# X rule --> 

ObserverX=300	#400
ObserverY=300
puts "<polyline points='#{ObserverX},150 #{ObserverX},#{AxeXstartY+10}' style='stroke: blue; stroke-width: .5'/>		<!-- observer vertical line -->"

ChargeX=450		#450
ChargeY=450
ChargeLineStopX=500
ChargeLineStopY=150

puts "<polyline points='#{ChargeX},#{ChargeY} #{ChargeX},#{AxeXstartY+10}'  class='dashedlines'/>				<!-- charge vertical line -->"
puts "<polyline points='#{AxeYstartX-10},#{ChargeY} #{ChargeX},#{ChargeY}' class='dashedlines'/>				<!-- charge horizontal line -->"
puts "<polyline points='#{AxeYstartX-10},#{ObserverY} #{ObserverX},#{ObserverY}' class='dashedlines'/>			<!-- t2 horizontal line -->"

	x1=ObserverX											# photonic curve calculatin
	y1=ObserverY
	x2=ChargeX
	y2=ChargeY
	la=-0.7												# handle length parametr
	xlist=[x1]
	ylist=[y1]
	xhandlelist=[]
	yhandlelist=[]
	n=10												# number of waves
	dx=(x2-x1)/n
	dy=(y2-y1)/n
	x=x1
	y=y1
	n.times do
		x0=x
		y0=y
		x+=dx
		y+=dy
		xlist.push x
		ylist.push y
		xhandle=(x0+x)/2+la*(y-y0)
		yhandle=(y0+y)/2+la*(x0-x)
		xhandlelist.push xhandle
		yhandlelist.push yhandle
	end

#(0..n-1).each{|i| puts "<circle cx='#{xhandlelist[i]}' cy='#{yhandlelist[i]}' r='2' fill='#007'/>"}	# spline conrtol handles
#(0..n).each{|i| puts "<circle cx='#{xlist[i]}' cy='#{ylist[i]}' r='2' fill='#000'/>"}			# spline nodes


puts "<path d='M #{ObserverX},#{ObserverY}"								# green photonic curve 
(1..n).each{|i| puts "S #{xhandlelist[i-1]},#{yhandlelist[i-1]} #{xlist[i]},#{ylist[i]}"}
puts "'	stroke='darkgreen' stroke-width='1'/>		"



puts "<path d='M #{ChargeX-50},#{ChargeY+90}	"							# blue charge random curve
puts "S #{ChargeX-20},#{ChargeY+40} #{ChargeX},#{ChargeY}"						# those strings contain
puts "S #{ChargeX-12},#{ChargeY-56} #{ChargeX+15},#{ChargeY-110}"					# many esoteric parameters
puts "S #{ChargeX+3},#{ChargeY-166} #{ChargeX+33},#{ChargeY-230}"
puts "S #{ChargeX+13},#{ChargeY-296} #{ChargeX+50},#{ChargeY-350}"
puts "'stroke='blue' stroke-width='1'/>"

puts "<circle cx='#{ChargeX}' cy='#{ChargeY}' r='3' fill='#000'/>		"
puts "<circle cx='#{ObserverX}' cy='#{ObserverY}' r='3' fill='#000'/>		"

puts "<style>.low{baseline-shift:sub; font-size:.6em}		.up{baseline-shift:super; font-size:.6em}</style>"
puts "<text x=#{AxeYstartX-30} y=#{ChargeY}> τ<tspan class='low'>1</tspan> </text>"
puts "<text x=#{AxeYstartX-30} y=#{ObserverY}> τ<tspan class='low'>2</tspan> </text>"
puts "<text x=#{AxeYstartX-30} y=#{AxeYstopY}> τ </text>"
puts "<text x=#{ChargeX} y=#{AxeXstartY+30}> x<tspan class='up'>k</tspan> (τ<tspan class='low'>1</tspan>) </text>"
puts "<text x=#{AxeXstopX} y=#{AxeXstartY+30}> x<tspan class='up'>k</tspan> </text>"

def note(x,y,a,text)
	puts " <text x=#{x} y=#{y} transform='rotate(#{a})' transform-origin='#{x} #{y}'> #{text} </text>"
end

note(ObserverX-10,ObserverY-30,-90,"Observer")
note(ChargeLineStopX+20,ChargeLineStopY+70,-85,"Charge")
note(500,530,-45,"Light cone")

PhotonLabelX=550
PhotonLabelY=360
note(PhotonLabelX,PhotonLabelY,-20,"Photon")
puts "<polyline points='#{PhotonLabelX-5},#{PhotonLabelY-5} 425,400' style='stroke: #000; stroke-width: .5'/>		<!-- charge vertical line -->"

puts "</svg>		"