Koda programa

 

var i=0; n=0; x=0; y=0; z=0; Fx=0; Fy=0; Fz=0; Mx=0; My=0; Mz=0; RMx=0; RMy=0; RMz=0; RFx=0; RFy=0; RFz=0; qx=0; qy=0; qz=0 
var d=0; c1=0; b=0; c2=0; c3=0; xrf=0; yrf=0; zrf=0;
var xrfx=0; zrfz=0; yrfy=0; xrf=0; zrf=0; yrf=0; qdx=0; qdy=0; qdz=0;
var a=new Array()
var Mox=new Array();
var Moy=new Array();
var Moz=new Array();
var Mox1=new Array();
var Moy1=new Array();
var Moz1=new Array();

//"zapis vnesenih podatkov v polja"

function zapis(form) {

			//"pregledovanje dolocene podpore"
			if(form.gumb[0].checked) {
			RMx=1
			RMy=1
			RMz=1
			RFx=1
			RFy=1
			RFz=1
			}
			if(form.gumb[1].checked){
			RMx=0
			RMy=0
			RMz=0
			RFx=1
			RFy=1
			RFz=1
				if(x!=0 || y!=0 || z!=0){
				alert("Vrednosti tocke x, y in z morajo biti 0 ! Prosim izbrisi in popravi !")
				}
			}
			if(form.gumb[2].checked){
			RMx=0
			RMy=0
			RMz=0
			RFx=0
			RFy=1
			RFz=1
			xrfx=RFx
			yrfy=RFy
			zrfz=RFz
			xrf=x
			yrf=y
			zrf=z
				if(x==0){
				alert("Vrednost x mora biti razlicna od 0 !  Prosim izbrisi in popravi !")
				}
			}
			if(form.gumb[3].checked){
			RMx=0
			RMy=0
			RMz=0
			RFx=1
			RFy=0
			RFz=1
			xrfx=RFx
			yrfy=RFy
			zrfz=RFz
			xrf=x
			yrf=y
			zrf=z
				if(y==0){
				alert("Vrednost y mora biti razlicna od 0 !  Prosim izbrisi in popravi !")
				}
			}
			if(form.gumb[4].checked){
			RMx=0
			RMy=0
			RMz=0
			RFx=1
			RFy=1
			RFz=0
			xrfx=RFx
			yrfy=RFy
			zrfz=RFz
			xrf=x
			yrf=y
			zrf=z
				if(z==0){
				alert("Vrednost z mora biti razlicna od 0 !  Prosim izbrisi in popravi !")
				}
			}
			if(form.gumb[5].checked){
			RMx=0
			RMy=0
			RMz=0
			RFx=0
			RFy=0
			RFz=0
			}
			
		n=i+1
		m=n
		a[i]=new Array(x,y,z,Fx,Fy,Fz,Mx,My,Mz,RMx,RMy,RMz,RFx,RFy,RFz,qx,qy,qz)
			//"kontrola pravilnost postavitve podpor"
			b=a[i][10]+b
			c1=a[i][12]+c1
			c2=a[i][13]+c2
			c3=a[i][14]+c3
			d=c1+c2+c3
			if(b==1 && d>3) {
			alert ("Prevec ali premalo podpor. S pritiskom na gumb Korekcija izbrises zadnji vnos.")
			}
			if(d==4 || d==6 || d==7) {
			alert ("Prevec ali premalo podpor. S pritiskom na gumb Korekcija izbrises zadnji vnos.")
			}

  i=i+1  
  
form.fx.value=0;
form.fy.value=0;
form.fz.value=0;
form.mx.value=0;
form.my.value=0;
form.mz.value=0;
form.q1x.value=0;
form.q1y.value=0;
form.q1z.value=0;
// standardna vrednost  kotov
form.kotx.value=42.8;
form.koty.value=20;
form.kotz.value=20;
}

//"potrditev vnosa"
function potrditevVnosa(form){
	if(confirm("Zelim vnesti podatke za to tocko!")){
	zapis(form);
	main();
	}
}

//"potrditev  izracuna"
function potrditevIzracuna(form){
	if(d==0){
	alert("Podpore niso definirane")
	}else{
		if(confirm("Zelim izracunati reakcije !")){
		reakcije(form)
		}
	}
}

//"korekcija trenutno vne�enih podatkov"
function korekcija(form){
if(i =0){
	alert("Vsi vnosi so ze izbrisani!")
	}else{
	i=i-1
	
	b=b-a[i][10]
	c1=c1-a[i][12]
	c2=c2-a[i][13]
	c3=c3-a[i][14]
	d=c1+c2+c3
	alert ("Izbrisan vnos �tevilka"+(i+1)+
	" Tocka: x="+a[i][0]+"y="+a[i][1]+"z="+a[i][2]+"!")
	}
}

//"izpis za kontrolo pravilnosti"
function izpis() {
	for(i=0; i n; i++) {
	document.write("") 
		for(var j=0; j 15; j++){
		document.write(a[i][j], ",")
		}
	}

}

//"izracun reakcij sil v smeri"
var rfx=0; rfy=0; rfz=0; rmx=0; rmy=0; rmz=0; rfx1=0; rfy1=0; rfz1=0; rfx2=0; rfy2=0; rfz2=0;
var rfx2b=0; rfy2b=0; rfz2b=0; rfx1a=0; rfy1a=0; rfz1a=0; rx=0; ry=0; rz=0; rsy=0; rsx=0; rsz=0;

	//"dodatni pogoji za vkljucitev kontinuiranih obremenitev"
	
function reakcije(form) {

	//"dolocitev konzolnega ali nosilca na dveh podporah"	
	for(i=0; i n; i++) {
		if(i==0){
			qdx=0;
			qdy=0;
			qdz=0;
			rx=0;
			ry=0;
			rz=0;
			}else{
			if(a[i-1][15]==0){
				qdx=0;
				}else{
				qdx=1;
				}
			if(a[i-1][16]==0){
				qdy=0;
				}else{
				qdy=1;
				}
			if(a[i-1][17]==0){
			qdz=0;
			}else{
			qdz=1;
			}
		rx=Math.sqrt((a[i-1][1]-a[i][1])*(a[i-1][1]-a[i][1])+(a[i-1][2]-a[i][2])*(a[i-1][2]-a[i][2]))
		ry=Math.sqrt((a[i-1][0]-a[i][0])*(a[i-1][0]-a[i][0])+(a[i-1][2]-a[i][2])*(a[i-1][2]-a[i][2]))
		rz=Math.sqrt((a[i-1][1]-a[i][1])*(a[i-1][1]-a[i][1])+(a[i-1][0]-a[i][0])*(a[i-1][0]-a[i][0]))
		rsx=0; rsy=0; rsz=0;
		rsx=((a[i][0]-a[i-1][0])/2)+a[i-1][0]
		rsy=((a[i][1]-a[i-1][1])/2)+a[i-1][1]
		rsz=((a[i][2]-a[i-1][2])/2)+a[i-1][2]
		}
			if(b==1) {
			rfx=-a[i][3]+qdx*a[i][15]*rx+rfx;
			rfy=-a[i][4]+qdy*a[i][16]*ry+rfy;
			rfz=-a[i][5]+qdz*a[i][17]*rz+rfz;
			rmx=-a[i][6]-a[i][4]*a[i][2]+a[i][5]*a[i][1]-rsy*qdz*a[i][17]*rz+rsz*qdy*a[i][16]*ry+rmx;
			rmy=-a[i][7]-a[i][3]*a[i][2]-a[i][5]*a[i][0]+rsx*qdz*a[i][17]*rz-rsz*qdx*a[i][15]*rx+rmy;
			rmz=-a[i][8]-a[i][3]*a[i][1]+a[i][4]*a[i][0]-rsx*qdy*a[i][16]*ry+rsy*qdx*a[i][15]*rx+rmz;
			}else {
				
				if(xrfx==0 && xrf!=0){
					rfx2=0;	
					rfz2=-((a[i][7]-a[i][2]*a[i][4]+a[i][5]*a[i][0]-rsx*qdz*a[i][17]*rz+rsz*qdx*a[i][15]*rx)/(xrf))
					rfy2=(-a[i][4]*a[i][0]+a[i][3]*a[i][1]+a[i][8]+rsx*qdy*a[i][16]*ry-rsy*qdx*a[i][15]*rx)/(xrf)
				}

				if(yrfy==0 && yrf!=0){
					rfy2=0;
					rfx2=-((a[i][8]-a[i][0]*a[i][4]+a[i][3]*a[i][1]+rsx*qdy*a[i][16]*ry-rsy*qdx*a[i][15]*rx)/(yrf))	
					rfz2=(a[i][6]+a[i][2]*a[i][4]-a[i][5]*a[i][1]+rsy*qdz*a[i][17]*rz-rsz*qdy*a[i][16]*ry)/(yrf)
				}

				if(zrfz==0 && zrf!=0){
					rfz2=0;
					rfy2=-((-a[i][5]*a[i][1]+a[i][4]*a[i][2]+a[i][6]+rsy*qdz*a[i][17]*rz-rsz*qdy*a[i][16]*ry)/(zrf))
					rfx2=(a[i][7]-a[i][3]*a[i][2]+a[i][5]*a[i][0]-rsx*qdz*a[i][17]*rz+rsz*qdx*a[i][15]*rx)/(zrf)
				}
			
			}								
			rfx2b=rfx2b+rfx2
			rfy2b=rfy2b+rfy2
			rfz2b=rfz2b+rfz2
			rfx1=-a[i][3]+qdx*a[i][15]*rx-rfx2
			rfy1=-a[i][4]+qdy*a[i][16]*ry-rfy2
			rfz1=-a[i][5]+qdz*a[i][17]*rz-rfz2
			rfx1a=rfx1a+rfx1
			rfy1a=rfy1a+rfy1
			rfz1a=rfz1a+rfz1
			
		
			//"vrednost reakcije v podpori 2 je rf..2b v podpori 1 pa rf..1 "
		}
		rfx1a=(Math.round(1000*rfx1a))/1000;
		rfy1a=(Math.round(1000*rfy1a))/1000;
		rfz1a=(Math.round(1000*rfz1a))/1000;
		rfx2b=(Math.round(1000*rfx2b))/1000;
		rfy2b=(Math.round(1000*rfy2b))/1000;
		rfz2b=(Math.round(1000*rfz2b))/1000;
		rfx=(Math.round(1000*rfx))/1000;
		rfy=(Math.round(1000*rfy))/1000;
		rfz=(Math.round(1000*rfz))/1000;
		rmx=(Math.round(1000*rmx))/1000;
		rmy=(Math.round(1000*rmy))/1000;
		rmz=(Math.round(1000*rmz))/1000;
	
	if(confirm("Zelim izracunati vrednosti notranjih velicin !")){
	notranjeVelicine(form)
	}
	
	
}

//izpis vrednosti
function rezultatiReakcij(){
	if(b==1){
		alert("Rezultati reakcij v podpori : Rfx="+rfx+"; Rfy="+rfy+"; Rfz="+rfz+";\n\ Rmx="+rmx+"; Rmy="+rmy+"; Rmz="+rmz+";");
	}else{
		alert("Rezultati reakcij v fiksni podpori : Rfx1="+rfx1a+"; Rfy1="+rfy1a+"; Rfz1="+rfz1a+";\n Rezultati reakcij v pomicni podpori : Rfx2="+rfx2b+"; Rfy2="+rfy2b+"; Rfz2="+rfz2b+";");
	}
}
//"izracun notranjih velicin nosilca!"



var ax=0; ay=0; az=0; bx=0; by=0; bz=0; cx=0; cy=0; cz=0; ra=0; rb=0; rc=0; nos=0; ty=0; tz=0; nos1=0; ty1=0; tz1=0;
var ax1=0; ay1=0; az1=0; bx1=0; by1=0; bz1=0; cx1=0; cy1=0; cz1=0; ra1=0; rb1=0; rc1=0;
var rmsx=0; rmsy=0; rmsz=0;
var dxy=0; dxz=0; dyz=0; dxy1=0; dxz1=0; dyz1=0; dqxy=0; dqxz=0; dqyz=0; dqxy1=0; dqxz1=0; dqyz1=0; mx=0; my=0; mz=0; mx1=0; my1=0; mz1=0; mmx=0; mmy=0; mmz=0; mmx1=0; mmy1=0; mmz1=0; fnx=0; fny=0; fnz=0; fnx1=0; fny1=0; fnz1=0; qx1=0; qy1=0; qz1=0; qx=0; qy=0; qz=0; rsx0=0; rsy0=0; rsz0=0;  razdaljax=0; razdaljay=0; razdaljaz=0; rqsx=0; rqsy=0; rqsz=0; mzn=0; mxn=0; myn=0; mzn1=0; mxn1=0; myn1=0;

var N=new Array();
var Ty=new Array();
var Tz=new Array();
var N1=new Array();
var Ty1=new Array();
var Tz1=new Array();

var bb=new Array(); var bb1=new Array(); var cc=new Array(); var cc1=new Array();
var rrb=new Array(); var rrb1=new Array(); var rrc=new Array(); var rrc1=new Array();
bb[i]=new Array(); bb1[i]=new Array(); cc[i]=new Array(); cc1[i]=new Array();

function notranjeVelicine(form) {


	for(var r=0; r n; r++) {
	//alert(r);
	mzn=0;
	mxn=0;
	myn=0;
	mzn1=0;
	mxn1=0;
	myn1=0;
	i=r;
		
			if(b!=1){
				if(i==0){
				ax1=a[i+1][0]-a[i][0]; 
				ay1=a[i+1][1]-a[i][1];
				az1=a[i+1][2]-a[i][2];
				ax=a[i+1][0]-a[i][0];
				ay=a[i+1][1]-a[i][1];
				az=a[i+1][2]-a[i][2];
				}
				if(i!=0 && i n-1){
				ax1=a[i][0]-a[i-1][0];
				ay1=a[i][1]-a[i-1][1];
				az1=a[i][2]-a[i-1][2];
				ax=a[i+1][0]-a[i][0];
				ay=a[i+1][1]-a[i][1];
				az=a[i+1][2]-a[i][2];
				}
				if(i==n-1){
				alert
				ax=a[i][0]-a[i-1][0];
				ay=a[i][1]-a[i-1][1];
				az=a[i][2]-a[i-1][2];
				ax1=a[i][0]-a[i-1][0];
				ay1=a[i][1]-a[i-1][1];
				az1=a[i][2]-a[i-1][2];
				}
			if(az1!=0 && az1 0){
			cx1=1;
			cy1=0;
			cz1=(ax1*cx1)/az1
			}
			if(az1!=0 && az1>0){
			cx1=-1;
			cy1=0;
			cz1=(ax1*cx)/az1
			}
			if(az1==0){
			cx1=0;
			cz1=1;
			cy1=0;
			}
		bx1=cy1*az1-cz1*ay1
		by1=cz1*ax1-cx1*az1
		bz1=cx1*ay1-cy1*ax1
		ra1=Math.sqrt(ax1*ax1+ay1*ay1+az1*az1)
		rb1=Math.sqrt(bx1*bx1+by1*by1+bz1*bz1)
		rc1=Math.sqrt(cx1*cx1+cy1*cy1+cz1*cz1)

		
			if(az!=0 && az 0){
			cx=1;
			cy=0;
			cz=(ax*cx)/az
			}
			if(az!=0 && az>0){
			cx=-1;
			cy=0;
			cz=(ax*cx)/az
			}
			if(az==0){
			cx=0;
			cz=1;
			cy=0;
			}
		bx=cy*az-cz*ay
		by=cz*ax-cx*az
		bz=cx*ay-cy*ax
		ra=Math.sqrt(ax*ax+ay*ay+az*az)
		rb=Math.sqrt(bx*bx+by*by+bz*bz)
		rc=Math.sqrt(cx*cx+cy*cy+cz*cz)
	
		bb[i]=new Array(); bb1[i]=new Array(); cc[i]=new Array(); cc1[i]=new Array();
		bb[i][0]=bx; bb[i][1]=by; bb[i][2]=bz; bb1[i][0]=bx1; bb1[i][1]=by1; bb1[i][2]=bz1;
		cc[i][0]=cx; cc[i][1]=cy; cc[i][2]=cz; cc1[i][0]=cx1; cc1[i][1]=cy1; cc1[i][2]=cz1;
		rrb[i]=rb; rrb1[i]=rb1; rrc[i]=rc; rrc1[i]=rc1;
		
//	"notranje sile v nosilcu na dveh podporah"
		nn=i+1
		nos1=0;
		ty1=0;
		tz1=0;
		ty=0;
		nos=0;
		tz=0;

		rmsx=a[i][0];
		rmsy=a[i][1];
		rmsz=a[i][2];

		

			for(i=0; i nn; i++) {
		//alert("i"+i);
		//alert("nn"+nn);
		
		if(i==0){
			qdx=0;
			qdy=0;
			qdz=0;
			rx=0;
			ry=0;
			rz=0;
			rsx0=0;
			rsy0=0;
			rsz0=0;
			
			}else{
			if(a[i-1][15]==0){
				qdx=0;
				}else{
				qdx=1;
				}
			if(a[i-1][16]==0){
				qdy=0;
				}else{
				qdy=1;
				}
			if(a[i-1][17]==0){
			qdz=0;
			}else{
			qdz=1;
			}
		rx=Math.sqrt((a[i-1][1]-a[i][1])*(a[i-1][1]-a[i][1])+(a[i-1][2]-a[i][2])*(a[i-1][2]-a[i][2]))
		ry=Math.sqrt((a[i-1][0]-a[i][0])*(a[i-1][0]-a[i][0])+(a[i-1][2]-a[i][2])*(a[i-1][2]-a[i][2]))
		rz=Math.sqrt((a[i-1][1]-a[i][1])*(a[i-1][1]-a[i][1])+(a[i-1][0]-a[i][0])*(a[i-1][0]-a[i][0]))
		rsx=0; rsy=0; rsz=0;
		rsx=((a[i][0]-a[i-1][0])/2)+a[i-1][0]
		rsy=((a[i][1]-a[i-1][1])/2)+a[i-1][1]
		rsz=((a[i][2]-a[i-1][2])/2)+a[i-1][2]

		rsx0=((-a[i][0]+a[i-1][0])/2)
		rsy0=((-a[i][1]+a[i-1][1])/2)
		rsz0=((-a[i][2]+a[i-1][2])/2)


		}

		qx=(qdx*a[i][15]*rx)*(ax/ra)+(qdy*a[i][16]*ry)*(ay/ra)+(qdz*a[i][17]*rz)*(az/ra)
		qx1=(qdx*a[i][15]*rx)*(ax1/ra1)+(qdy*a[i][16]*ry)*(ay1/ra1)+(qdz*a[i][17]*rz)*(az1/ra1)
		qy=(qdx*a[i][15]*rx)*(bx/rb)+(qdy*a[i][16]*ry)*(by/rb)+(qdz*a[i][17]*rz)*(bz/rb)
		qy1=(qdx*a[i][15]*rx)*(bx1/rb1)+(qdy*a[i][16]*ry)*(by1/rb1)+(qdz*a[i][17]*rz)*(bz1/rb1)
		qz=(qdx*a[i][15]*rx)*(cx/rc)+(qdy*a[i][16]*ry)*(cy/rc)+(qdz*a[i][17]*rz)*(cz/rc)
		qz1=(qdx*a[i][15]*rx)*(cx1/rc1)+(qdy*a[i][16]*ry)*(cy1/rc1)+(qdz*a[i][17]*rz)*(cz1/rc1)

		mmx=(a[i][6])*(ax/ra)+(a[i][7])*(ay/ra)+(a[i][8])*(az/ra)
		mmx1=(a[i][6])*(ax1/ra1)+(a[i][7])*(ay1/ra1)+(a[i][8])*(az1/ra1)
		mmy=(a[i][6])*(bx/rb)+(a[i][7])*(by/rb)+(a[i][8])*(bz/rb)
		mmy1=(a[i][6])*(bx1/rb1)+(a[i][7])*(by1/rb1)+(a[i][8])*(bz1/rb1)
		mmz=(a[i][6])*(cx/rc)+(a[i][7])*(cy/rc)+(a[i][8])*(cz/rc)
		mmz1=(a[i][6])*(cx1/rc1)+(a[i][7])*(cy1/rc1)+(a[i][8])*(cz1/rc1)

		razdaljax=a[i][0]-rmsx
		razdaljay=a[i][1]-rmsy
		razdaljaz=a[i][2]-rmsz

		rqsx=razdaljax+rsx0
		rqsy=razdaljay+rsy0
		rqsz=razdaljaz+rsz0

		dxy1=(cx1*razdaljax+cy1*razdaljay+cz1*razdaljaz)/rc1
		dxy=(cx*razdaljax+cy*razdaljay+cz*razdaljaz)/rc
		dxz=(bx*razdaljax+by*razdaljay+bz*razdaljaz)/rb
		dxz1=(bx1*razdaljax+by1*razdaljay+bz1*razdaljaz)/rb1
		dyz=(ax*razdaljax+ay*razdaljay+az*razdaljaz)/ra
		dyz1=(ax1*razdaljax+ay1*razdaljay+az1*razdaljaz)/ra1

		dqxy1=(cx1*rqsx+cy1*rqsy+cz1*rqsz)/rc1
		dqxy=(cx*rqsx+cy*rqsy+cz*rqsz)/rc
		dqxz=(bx*rqsx+by*rqsy+bz*rqsz)/rb
		dqxz1=(bx1*rqsx+by1*rqsy+bz1*rqsz)/rb1
		dqyz=(ax*rqsx+ay*rqsy+az*rqsz)/ra
		dqyz1=(ax1*rqsx+ay1*rqsy+az1*rqsz)/ra1

		//alert("razdaljax"+razdaljax)
		//alert("dyz"+dyz)
		//alert("dyz1"+dyz1)

		
		if(i==0){
		if(a[i][12]==0 && a[i][13]==0 && a[i][14]==0){
		podx=0;
		pody=0;
		podz=0;
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i][12]==0 && a[i][13]!=0){
		podx=0;
		pody=1;
		podz=1;
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i][12]!=0 && a[i][13]==0){
		podx=1;
		pody=0;
		podz=1;
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i][12]!=0 && a[i][14]==0){
		podx=1;
		pody=1;
		podz=0;
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i][12]==1 && a[i][13]==1 && a[i][14]==1){
		podx=0;
		pody=0;
		podz=0;
		pdx=1;
		pdy=1;
		pdz=1;
		}
		nos=-((ax/ra)*(a[i][3]-qdx*a[i][15]*rx+rfx1a*pdx+rfx2b*podx)+(ay/ra)*(a[i][4]-qdy*a[i][16]*ry+rfy2b*pody+rfy1a*pdy)+(az/ra)*(a[i][5]-qdz*a[i][17]*rz+rfz1a*pdz+rfz2b*podz))+nos
			ty=-((bx/rb)*(a[i][3]-qdx*a[i][15]*rx+rfx1a*pdx+rfx2b*podx)+(by/rb)*(a[i][4]-qdy*a[i][16]*ry+rfy2b*pody+rfy1a*pdy)+(bz/rb)*(a[i][5]-qdz*a[i][17]*rz+rfz1a*pdz+rfz2b*podz))+ty
	
		tz=-((cx/rc)*(a[i][3]-qdx*a[i][15]*rx+rfx1a*pdx+rfx2b*podx)+(cy/rc)*(a[i][4]-qdy*a[i][16]*ry+rfy2b*pody+rfy1a*pdy)+(cz/rc)*(a[i][5]-qdz*a[i][17]*rz+rfz1a*pdz+rfz2b*podz))+tz
		
		fnx1=(ax1/ra1)*(a[i][3]+rfx1a*pdx+rfx2b*podx)+(ay1/ra1)*(a[i][4]+rfy2b*pody+rfy1a*pdy)+(az1/ra1)*(a[i][5]+rfz1a*pdz+rfz2b*podz);
		fny1=(bx1/rb1)*(a[i][3]+rfx1a*pdx+rfx2b*podx)+(by1/rb1)*(a[i][4]+rfy2b*pody+rfy1a*pdy)+(bz1/rb1)*(a[i][5]+rfz1a*pdz+rfz2b*podz);
		fnz1=(cx1/rc1)*(a[i][3]+rfx1a*pdx+rfx2b*podx)+(cy1/rc1)*(a[i][4]+rfy2b*pody+rfy1a*pdy)+(cz1/rc1)*(a[i][5]+rfz1a*pdz+rfz2b*podz);
		mx1=-(-dxz1*fnz1+dxy1*fny1-dqxy1*qy1+dqxz1*qz1+mmx1)
		my1=-(dyz1*fnz1-dxy1*fnx1+dqxy1*qx1-dqyz1*qz1+mmy1)
		mz1=-(dxz1*fnx1-dyz1*fny1+dqyz1*qy1-dqxz1*qx1+mmz1)


		fnx=(ax/ra)*(a[i][3]+rfx1a*pdx+rfx2b*podx)+(ay/ra)*(a[i][4]+rfy2b*pody+rfy1a*pdy)+(az/ra)*(a[i][5]+rfz1a*pdz+rfz2b*podz);
		fny=(bx/rb)*(a[i][3]+rfx1a*pdx+rfx2b*podx)+(by/rb)*(a[i][4]+rfy2b*pody+rfy1a*pdy)+(bz/rb)*(a[i][5]+rfz1a*pdz+rfz2b*podz);
		fnz=(cx/rc)*(a[i][3]+rfx1a*pdx+rfx2b*podx)+(cy/rc)*(a[i][4]+rfy2b*pody+rfy1a*pdy)+(cz/rc)*(a[i][5]+rfz1a*pdz+rfz2b*podz);
		
		mx=-(-dxz*fnz+dxy*fny-dqxy*qy+dqxz*qz+mmx)
		my=-(dyz*fnz-dxy*fnx+dqxy*qx-dqyz*qz+mmy)
		mz=-(dxz*fnx-dyz*fny+dqyz*qy-dqxz*qx+mmz)
		


		}else{
		if(a[i-1][12]==0 && a[i-1][13]==0 && a[i-1][14]==0){
		podx=0;
		pody=0;
		podz=0;
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i-1][12]==0 && a[i-1][13]!=0){
		podx=0;
		pody=1;
		podz=1;
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i-1][12]!=0 && a[i-1][13]==0){
		podx=1;
		pody=0;
		podz=1;
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i-1][12]!=0 && a[i-1][14]==0){
		podx=1;
		pody=1;
		podz=0;
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i-1][12]==1 && a[i-1][13]==1 && a[i-1][14]==1){
		podx=0;
		pody=0;
		podz=0;
		pdx=1;
		pdy=1;
		pdz=1;
		}
		nos1=-((ax1/ra1)*(a[i-1][3]-qdx*a[i][15]*rx+rfx1a*pdx+rfx2b*podx)+(ay1/ra1)*(a[i-1][4]-qdy*a[i][16]*ry+rfy2b*pody+rfy1a*pdy)+(az1/ra1)*(a[i-1][5]-qdz*a[i][17]*rz+rfz1a*pdz+rfz2b*podz))+nos1
		
		ty1=-((bx1/rb1)*(a[i-1][3]-qdx*a[i][15]*rx+rfx1a*pdx+rfx2b*podx)+(by1/rb1)*(a[i-1][4]-qdy*a[i][16]*ry+rfy2b*pody+rfy1a*pdy)+(bz1/rb1)*(a[i-1][5]-qdz*a[i][17]*rz+rfz1a*pdz+rfz2b*podz))+ty1
		
		tz1=-((cx1/rc1)*(a[i-1][3]-qdx*a[i][15]*rx+rfx1a*pdx+rfx2b*podx)+(cy1/rc1)*(a[i-1][4]-qdy*a[i][16]*ry+rfy2b*pody+rfy1a*pdy)+(cz1/rc1)*(a[i-1][5]-qdz*a[i][17]*rz+rfz1a*pdz+rfz2b*podz))+tz1
	

		if(a[i][12]==0 && a[i][13]==0 && a[i][14]==0){
		podx=0;
		pody=0;
		podz=0;
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i][12]==0 && a[i][13]!=0){
		podx=0;
		pody=1;
		podz=1;
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i][12]!=0 && a[i][13]==0){
		podx=1;
		pody=0;
		podz=1;
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i][12]!=0 && a[i][14]==0){
		podx=1;
		pody=1;
		podz=0;
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i][12]==1 && a[i][13]==1 && a[i][14]==1){
		podx=0;
		pody=0;
		podz=0;
		pdx=1;
		pdy=1;
		pdz=1;
		}
		nos=-((ax/ra)*(a[i][3]-qdx*a[i][15]*rx+rfx1a*pdx+rfx2b*podx)+(ay/ra)*(a[i][4]-qdy*a[i][16]*ry+rfy2b*pody+rfy1a*pdy)+(az/ra)*(a[i][5]-qdz*a[i][17]*rz+rfz1a*pdz+rfz2b*podz))+nos

		ty=-((bx/rb)*(a[i][3]-qdx*a[i][15]*rx+rfx1a*pdx+rfx2b*podx)+(by/rb)*(a[i][4]-qdy*a[i][16]*ry+rfy2b*pody+rfy1a*pdy)+(bz/rb)*(a[i][5]-qdz*a[i][17]*rz+rfz1a*pdz+rfz2b*podz))+ty
		
		tz=-((cx/rc)*(a[i][3]-qdx*a[i][15]*rx+rfx1a*pdx+rfx2b*podx)+(cy/rc)*(a[i][4]-qdy*a[i][16]*ry+rfy2b*pody+rfy1a*pdy)+(cz/rc)*(a[i][5]-qdz*a[i][17]*rz+rfz1a*pdz+rfz2b*podz))+tz
	
			
		fnx1=(ax1/ra1)*(a[i][3]+rfx1a*pdx+rfx2b*podx)+(ay1/ra1)*(a[i][4]+rfy2b*pody+rfy1a*pdy)+(az1/ra1)*(a[i][5]+rfz1a*pdz+rfz2b*podz);
		fny1=(bx1/rb1)*(a[i][3]+rfx1a*pdx+rfx2b*podx)+(by1/rb1)*(a[i][4]+rfy2b*pody+rfy1a*pdy)+(bz1/rb1)*(a[i][5]+rfz1a*pdz+rfz2b*podz);
		fnz1=(cx1/rc1)*(a[i][3]+rfx1a*pdx+rfx2b*podx)+(cy1/rc1)*(a[i][4]+rfy2b*pody+rfy1a*pdy)+(cz1/rc1)*(a[i][5]+rfz1a*pdz+rfz2b*podz);
		mx1=-(-dxz1*fnz1+dxy1*fny1-dqxy1*qy1+dqxz1*qz1+mmx1)
		my1=-(dyz1*fnz1-dxy1*fnx1+dqxy1*qx1-dqyz1*qz1+mmy1)
		mz1=-(dxz1*fnx1-dyz1*fny1+dqyz1*qy1-dqxz1*qx1+mmz1)

		fnx=(ax/ra)*(a[i][3]+rfx1a*pdx+rfx2b*podx)+(ay/ra)*(a[i][4]+rfy2b*pody+rfy1a*pdy)+(az/ra)*(a[i][5]+rfz1a*pdz+rfz2b*podz);
		fny=(bx/rb)*(a[i][3]+rfx1a*pdx+rfx2b*podx)+(by/rb)*(a[i][4]+rfy2b*pody+rfy1a*pdy)+(bz/rb)*(a[i][5]+rfz1a*pdz+rfz2b*podz);
		fnz=(cx/rc)*(a[i][3]+rfx1a*pdx+rfx2b*podx)+(cy/rc)*(a[i][4]+rfy2b*pody+rfy1a*pdy)+(cz/rc)*(a[i][5]+rfz1a*pdz+rfz2b*podz);
		
		mx=-(-dxz*fnz+dxy*fny-dqxy*qy+dqxz*qz+mmx)
		my=-(dyz*fnz-dxy*fnx+dqxy*qx-dqyz*qz+mmy)
		mz=-(dxz*fnx-dyz*fny+dqyz*qy-dqxz*qx+mmz)
		}
		mxn=mx+mxn
		myn=my+myn
		mzn=mz+mzn
		mxn1=mx1+mxn1
		myn1=my1+myn1
		mzn1=mz1+mzn1
		//alert("fny"+fny);
		//alert("mzn"+mzn);
		//alert("mxn"+mxn);
		}
		}else{
				//"se za konzolo"
			if(i==0){
				ax1=a[i+1][0]-a[i][0];
				ay1=a[i+1][1]-a[i][1];
				az1=a[i+1][2]-a[i][2];
				ax=a[i+1][0]-a[i][0];
				ay=a[i+1][1]-a[i][1];
				az=a[i+1][2]-a[i][2];
				}
				if(i!=0 && i n-1){
				ax1=a[i][0]-a[i-1][0];
				ay1=a[i][1]-a[i-1][1];
				az1=a[i][2]-a[i-1][2];
				ax=a[i+1][0]-a[i][0];
				ay=a[i+1][1]-a[i][1];
				az=a[i+1][2]-a[i][2];
				}
				if(i==n-1){
				alert
				ax=a[i][0]-a[i-1][0];
				ay=a[i][1]-a[i-1][1];
				az=a[i][2]-a[i-1][2];
				ax1=a[i][0]-a[i-1][0];
				ay1=a[i][1]-a[i-1][1];
				az1=a[i][2]-a[i-1][2];
				}
			if(az1!=0 && az1<0){
			cx1=1;
			cy1=0;
			cz1=(ax1*cx1)/az1
			}
			if(az1!=0 && az1>0){
			cx1=-1;
			cy1=0;
			cz1=(ax1*cx)/az1
			}
			if(az1==0){
			cx1=0;
			cz1=1;
			cy1=0;
			}
		bx1=cy1*az1-cz1*ay1
		by1=cz1*ax1-cx1*az1
		bz1=cx1*ay1-cy1*ax1
		ra1=Math.sqrt(ax1*ax1+ay1*ay1+az1*az1)
		rb1=Math.sqrt(bx1*bx1+by1*by1+bz1*bz1)
		rc1=Math.sqrt(cx1*cx1+cy1*cy1+cz1*cz1)

		
			if(az!=0 && az 0){
			cx=1;
			cy=0;
			cz=(ax*cx)/az
			}
			if(az!=0 && az>0){
			cx=-1;
			cy=0;
			cz=(ax*cx)/az
			}
			if(az==0){
			cx=0;
			cz=1;
			cy=0;
			}
		bx=cy*az-cz*ay
		by=cz*ax-cx*az
		bz=cx*ay-cy*ax
		ra=Math.sqrt(ax*ax+ay*ay+az*az)
		rb=Math.sqrt(bx*bx+by*by+bz*bz)
		rc=Math.sqrt(cx*cx+cy*cy+cz*cz)
		
		bb[i]=new Array(); bb1[i]=new Array(); cc[i]=new Array(); cc1[i]=new Array(); 
		bb[i][0]=bx; bb[i][1]=by; bb[i][2]=bz; bb1[i][0]=bx1; bb1[i][1]=by1; bb1[i][2]=bz1;
		cc[i][0]=cx; cc[i][1]=cy; cc[i][2]=cz; cc1[i][0]=cx1; cc1[i][1]=cy1; cc1[i][2]=cz1;
		rrb[i]=rb; rrb1[i]=rb1; rrc[i]=rc; rrc1[i]=rc1;
		

			nn=i+1
		nos1=0;
		ty1=0;
		tz1=0;
		ty=0;
		nos=0;
		tz=0;

		rmsx=a[i][0];
		rmsy=a[i][1];
		rmsz=a[i][2];

		

			for(i=0; i nn; i++) {
		//alert("i"+i);
		//alert("nn"+nn);
		
		if(i==0){
			qdx=0;
			qdy=0;
			qdz=0;
			rx=0;
			ry=0;
			rz=0;
			rsx0=0;
			rsy0=0;
			rsz0=0;
			
			}else{
			if(a[i-1][15]==0){
				qdx=0;
				}else{
				qdx=1;
				}
			if(a[i-1][16]==0){
				qdy=0;
				}else{
				qdy=1;
				}
			if(a[i-1][17]==0){
			qdz=0;
			}else{
			qdz=1;
			}
		rx=Math.sqrt((a[i-1][1]-a[i][1])*(a[i-1][1]-a[i][1])+(a[i-1][2]-a[i][2])*(a[i-1][2]-a[i][2]))
		ry=Math.sqrt((a[i-1][0]-a[i][0])*(a[i-1][0]-a[i][0])+(a[i-1][2]-a[i][2])*(a[i-1][2]-a[i][2]))
		rz=Math.sqrt((a[i-1][1]-a[i][1])*(a[i-1][1]-a[i][1])+(a[i-1][0]-a[i][0])*(a[i-1][0]-a[i][0]))
		rsx=0; rsy=0; rsz=0;
		rsx=((a[i][0]-a[i-1][0])/2)+a[i-1][0]
		rsy=((a[i][1]-a[i-1][1])/2)+a[i-1][1]
		rsz=((a[i][2]-a[i-1][2])/2)+a[i-1][2]

		rsx0=((-a[i][0]+a[i-1][0])/2)
		rsy0=((-a[i][1]+a[i-1][1])/2)
		rsz0=((-a[i][2]+a[i-1][2])/2)


		}

		qx=(qdx*a[i][15]*rx)*(ax/ra)+(qdy*a[i][16]*ry)*(ay/ra)+(qdz*a[i][17]*rz)*(az/ra)
		qx1=(qdx*a[i][15]*rx)*(ax1/ra1)+(qdy*a[i][16]*ry)*(ay1/ra1)+(qdz*a[i][17]*rz)*(az1/ra1)
		qy=(qdx*a[i][15]*rx)*(bx/rb)+(qdy*a[i][16]*ry)*(by/rb)+(qdz*a[i][17]*rz)*(bz/rb)
		qy1=(qdx*a[i][15]*rx)*(bx1/rb1)+(qdy*a[i][16]*ry)*(by1/rb1)+(qdz*a[i][17]*rz)*(bz1/rb1)
		qz=(qdx*a[i][15]*rx)*(cx/rc)+(qdy*a[i][16]*ry)*(cy/rc)+(qdz*a[i][17]*rz)*(cz/rc)
		qz1=(qdx*a[i][15]*rx)*(cx1/rc1)+(qdy*a[i][16]*ry)*(cy1/rc1)+(qdz*a[i][17]*rz)*(cz1/rc1)

		mmx=(a[i][6])*(ax/ra)+(a[i][7])*(ay/ra)+(a[i][8])*(az/ra)
		mmx1=(a[i][6])*(ax1/ra1)+(a[i][7])*(ay1/ra1)+(a[i][8])*(az1/ra1)
		mmy=(a[i][6])*(bx/rb)+(a[i][7])*(by/rb)+(a[i][8])*(bz/rb)
		mmy1=(a[i][6])*(bx1/rb1)+(a[i][7])*(by1/rb1)+(a[i][8])*(bz1/rb1)
		mmz=(a[i][6])*(cx/rc)+(a[i][7])*(cy/rc)+(a[i][8])*(cz/rc)
		mmz1=(a[i][6])*(cx1/rc1)+(a[i][7])*(cy1/rc1)+(a[i][8])*(cz1/rc1)

		kmmx=(rmx)*(ax/ra)+(rmy)*(ay/ra)+(rmz)*(az/ra)
		kmmx1=(rmx)*(ax1/ra1)+(rmy)*(ay1/ra1)+(rmz)*(az1/ra1)
		kmmy=(rmx)*(bx/rb)+(rmy)*(by/rb)+(rmz)*(bz/rb)
		kmmy1=(rmx)*(bx1/rb1)+(rmy)*(by1/rb1)+(rmz)*(bz1/rb1)
		kmmz=(rmx)*(cx/rc)+(rmy)*(cy/rc)+(rmz)*(cz/rc)
		kmmz1=(rmx)*(cx1/rc1)+(rmy)*(cy1/rc1)+(rmz)*(cz1/rc1)

		razdaljax=a[i][0]-rmsx
		razdaljay=a[i][1]-rmsy
		razdaljaz=a[i][2]-rmsz

		rqsx=razdaljax+rsx0
		rqsy=razdaljay+rsy0
		rqsz=razdaljaz+rsz0

		dxy1=(cx1*razdaljax+cy1*razdaljay+cz1*razdaljaz)/rc1
		dxy=(cx*razdaljax+cy*razdaljay+cz*razdaljaz)/rc
		dxz=(bx*razdaljax+by*razdaljay+bz*razdaljaz)/rb
		dxz1=(bx1*razdaljax+by1*razdaljay+bz1*razdaljaz)/rb1
		dyz=(ax*razdaljax+ay*razdaljay+az*razdaljaz)/ra
		dyz1=(ax1*razdaljax+ay1*razdaljay+az1*razdaljaz)/ra1

		dqxy1=(cx1*rqsx+cy1*rqsy+cz1*rqsz)/rc1
		dqxy=(cx*rqsx+cy*rqsy+cz*rqsz)/rc
		dqxz=(bx*rqsx+by*rqsy+bz*rqsz)/rb
		dqxz1=(bx1*rqsx+by1*rqsy+bz1*rqsz)/rb1
		dqyz=(ax*rqsx+ay*rqsy+az*rqsz)/ra
		dqyz1=(ax1*rqsx+ay1*rqsy+az1*rqsz)/ra1

		//alert("razdaljax"+razdaljax)
		//alert("dyz"+dyz)
		//alert("dyz1"+dyz1)
//alert("i"+i);
		if(i==0){
		if(a[i][12]==0 && a[i][13]==0 && a[i][14]==0){
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i][12]!=0 && a[i][13]!=0 && a[i][14]!=0){
		pdx=1;
		pdy=1;
		pdz=1;
		}
		
		nos=-((ax/ra)*(a[i][3]-qdx*a[i][15]*rx+rfx*pdx)+(ay/ra)*(a[i][4]-qdy*a[i][16]*ry+rfy*pdy)+(az/ra)*(a[i][5]-qdz*a[i][17]*rz+rfz*pdz))+nos
		ty=-((bx/rb)*(a[i][3]-qdx*a[i][15]*rx+rfx*pdx)+(by/rb)*(a[i][4]-qdy*a[i][16]*ry+rfy*pdy)+(bz/rb)*(a[i][5]-qdz*a[i][17]*rz+rfz*pdz))+ty
		tz=-((cx/rc)*(a[i][3]-qdx*a[i][15]*rx+rfx*pdx)+(cy/rc)*(a[i][4]-qdy*a[i][16]*ry+rfy*pdy)+(cz/rc)*(a[i][5]-qdz*a[i][17]*rz+rfz*pdz))+tz
		
		fnx1=(ax1/ra1)*(a[i][3]+rfx*pdx)+(ay1/ra1)*(a[i][4]+rfy*pdy)+(az1/ra1)*(a[i][5]+rfz*pdz);
		fny1=(bx1/rb1)*(a[i][3]+rfx*pdx)+(by1/rb1)*(a[i][4]+rfy*pdy)+(bz1/rb1)*(a[i][5]+rfz*pdz);
		fnz1=(cx1/rc1)*(a[i][3]+rfx*pdx)+(cy1/rc1)*(a[i][4]+rfy*pdy)+(cz1/rc1)*(a[i][5]+rfz*pdz);
		mx1=-(-dxz1*fnz1+dxy1*fny1-dqxy1*qy1+dqxz1*qz1+kmmx1*pdx+mmx1)
		my1=-(dyz1*fnz1-dxy1*fnx1+dqxy1*qx1-dqyz1*qz1+kmmy1*pdy+mmy1)
		mz1=-(dxz1*fnx1-dyz1*fny1+dqyz1*qy1-dqxz1*qx1+kmmz1*pdz+mmz1)
//alert("1"+fny1);
//alert("dyz1"+dyz1);
//alert("mz1"+mz1);
		fnx=(ax/ra)*(a[i][3]+rfx*pdx)+(ay/ra)*(a[i][4]+rfy*pdy)+(az/ra)*(a[i][5]+rfz*pdz);
		fny=(bx/rb)*(a[i][3]+rfx*pdx)+(by/rb)*(a[i][4]+rfy*pdy)+(bz/rb)*(a[i][5]+rfz*pdz);
		fnz=(cx/rc)*(a[i][3]+rfx*pdx)+(cy/rc)*(a[i][4]+rfy*pdy)+(cz/rc)*(a[i][5]+rfz*pdz);
		
		mx=-(-dxz*fnz+dxy*fny-dqxy*qy+dqxz*qz+kmmx*pdx+mmx)
		my=-(dyz*fnz-dxy*fnx+dqxy*qx-dqyz*qz+kmmy*pdy+mmy)
		mz=-(dxz*fnx-dyz*fny+dqyz*qy-dqxz*qx+kmmz*pdz+mmz)
		


		}else{
		if(a[i-1][12]==0 && a[i-1][13]==0 && a[i-1][14]==0){
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i-1][12]!=0 && a[i-1][13]!=0 && a[i-1][14]!=0){
		pdx=1;
		pdy=1;
		pdz=1;
		}
		
		nos1=-((ax1/ra1)*(a[i-1][3]-qdx*a[i][15]*rx+rfx*pdx)+(ay1/ra1)*(a[i-1][4]-qdy*a[i][16]*ry+rfy*pdy)+(az1/ra1)*(a[i-1][5]-qdz*a[i][17]*rz+rfz*pdz))+nos1
		
		ty1=-((bx1/rb1)*(a[i-1][3]-qdx*a[i][15]*rx+rfx*pdx)+(by1/rb1)*(a[i-1][4]-qdy*a[i][16]*ry+rfy*pdy)+(bz1/rb1)*(a[i-1][5]-qdz*a[i][17]*rz+rfz*pdz))+ty1
		
		tz1=-((cx1/rc1)*(a[i-1][3]-qdx*a[i][15]*rx+rfx*pdx)+(cy1/rc1)*(a[i-1][4]-qdy*a[i][16]*ry+rfy*pdy)+(cz1/rc1)*(a[i-1][5]-qdz*a[i][17]*rz+rfz*pdz))+tz1
	

		if(a[i][12]==0 && a[i][13]==0 && a[i][14]==0){
		pdx=0;
		pdy=0;
		pdz=0;
		}
		if(a[i][12]!=0 && a[i][13]!=0 && a[i-1][14]!=0){
		pdx=1;
		pdy=1;
		pdz=1;
		}
		
		nos=-((ax/ra)*(a[i][3]-qdx*a[i][15]*rx+rfx*pdx)+(ay/ra)*(a[i][4]-qdy*a[i][16]*ry+rfy*pdy)+(az/ra)*(a[i][5]-qdz*a[i][17]*rz+rfz*pdz))+nos
		ty=-((bx/rb)*(a[i][3]-qdx*a[i][15]*rx+rfx*pdx)+(by/rb)*(a[i][4]-qdy*a[i][16]*ry+rfy*pdy)+(bz/rb)*(a[i][5]-qdz*a[i][17]*rz+rfz*pdz))+ty
		tz=-((cx/rc)*(a[i][3]-qdx*a[i][15]*rx+rfx*pdx)+(cy/rc)*(a[i][4]-qdy*a[i][16]*ry+rfy*pdy)+(cz/rc)*(a[i][5]-qdz*a[i][17]*rz+rfz*pdz))+tz
		
		fnx1=(ax1/ra1)*(a[i][3]+rfx*pdx)+(ay1/ra1)*(a[i][4]+rfy*pdy)+(az1/ra1)*(a[i][5]+rfz*pdz);
		fny1=(bx1/rb1)*(a[i][3]+rfx*pdx)+(by1/rb1)*(a[i][4]+rfy*pdy)+(bz1/rb1)*(a[i][5]+rfz*pdz);
		fnz1=(cx1/rc1)*(a[i][3]+rfx*pdx)+(cy1/rc1)*(a[i][4]+rfy*pdy)+(cz1/rc1)*(a[i][5]+rfz*pdz);

		mx1=-(-dxz1*fnz1+dxy1*fny1-dqxy1*qy1+dqxz1*qz1+kmmx1*pdx+mmx1)
		my1=-(dyz1*fnz1-dxy1*fnx1+dqxy1*qx1-dqyz1*qz1+kmmy1*pdy+mmy1)
		mz1=-(dxz1*fnx1-dyz1*fny1+dqyz1*qy1-dqxz1*qx1+kmmz1*pdz+mmz1)
//alert("2"+fny1);
//alert("dyz1"+dyz1);
//alert("mz2"+mz1);
		fnx=(ax/ra)*(a[i][3]+rfx*pdx)+(ay/ra)*(a[i][4]+rfy*pdy)+(az/ra)*(a[i][5]+rfz*pdz);
		fny=(bx/rb)*(a[i][3]+rfx*pdx)+(by/rb)*(a[i][4]+rfy*pdy)+(bz/rb)*(a[i][5]+rfz*pdz);
		fnz=(cx/rc)*(a[i][3]+rfx*pdx)+(cy/rc)*(a[i][4]+rfy*pdy)+(cz/rc)*(a[i][5]+rfz*pdz);
		

		mx=-(-dxz*fnz+dxy*fny-dqxy*qy+dqxz*qz+kmmx*pdx+mmx)
		my=-(dyz*fnz-dxy*fnx+dqxy*qx-dqyz*qz+kmmy*pdy+mmy)
		mz=-(dxz*fnx-dyz*fny+dqyz*qy-dqxz*qx+kmmz*pdz+mmz)
		}
		

		mxn=mx+mxn
		myn=my+myn
		mzn=mz+mzn
		mxn1=mx1+mxn1
		myn1=my1+myn1
		mzn1=mz1+mzn1

		//alert("fny"+fny);
		//alert("mzn1"+mzn1);
		}
		}
	
		Ty[r]=(Math.round(1000*ty))/1000;
		N[r]=(Math.round(1000*nos))/1000;
		N1[r]=(Math.round(1000*nos1))/1000;
		Tz[r]=(Math.round(1000*tz))/1000;
		Tz1[r]=(Math.round(1000*tz1))/1000;
		Ty1[r]=(Math.round(1000*ty1))/1000;
		Mox[r]=(Math.round(1000*mxn))/1000;
		Moy[r]=(Math.round(1000*myn))/1000;
		Moz[r]=(Math.round(1000*mzn))/1000;
		Mox1[r]=(Math.round(1000*mxn1))/1000;
		Moy1[r]=(Math.round(1000*myn1))/1000;
		Moz1[r]=(Math.round(1000*mzn1))/1000;
	
	}
		
		
}
	



		//"izris parametrov"

function koordinat(){
var ks=new Array();
 ks[0]=new Ppoint(0.3,0.5+0.42);
 ks[1]=new Ppoint(0.3-0.008,0.5+0.42);
 ks[2]=new Ppoint(0.3,0.5+0.45);
 ks[3]=new Ppoint(0.3+0.008,0.5+0.42);
 ks[4]=new Ppoint(ks[0].x,ks[0].y);
 ks[5]=new Ppoint(0.3,0.5);
 ks[6]=new Ppoint(0.3+0.6459,0.5-0.2633);
 ks[7]=new Ppoint(0.3+0.649,0.5-0.2558);
 ks[8]=new Ppoint(0.3+0.6737,0.5-0.2746);
 ks[9]=new Ppoint(0.3+0.6429,0.5-0.2707);
 ks[10]=new Ppoint(ks[6].x,ks[6].y);

var kor_kriz=new Ppoint_list(11, ks);


 pset_line_colr_ind(2);
 pset_text_colr_ind(2);
 ptext(new Ppoint(0.25,0.5+0.43), "Y");
 ptext(new Ppoint(0.33+0.63,0.5-0.25), "X");
 ppolyline(kor_kriz);
}

function koordinat1(){

 var ks1=new Array();
 ks1[0]=new Ppoint(0.3, 0.5);
 ks1[1]=new Ppoint(0.3-0.231,0.5-0.283);
 ks1[2]=new Ppoint(0.3-0.2248,0.5-0.288);
 ks1[3]=new Ppoint(0.3-0.25,0.5-0.3062);
 ks1[4]=new Ppoint(0.3-0.2372,0.5-0.2779);
 ks1[5]=new Ppoint(0.3-0.231,0.5-0.283);
 ks1[6]=new Ppoint(ks1[0].x, ks1[0].y);

 var kor_kriz1=new Ppoint_list(7, ks1);

  pset_line_colr_ind(2);
 ppolyline(kor_kriz1);
 pset_text_colr_ind(2);
 ptext(new Ppoint(0.32-0.24,0.48-0.29), "Z");
}

//funkcije za prikaz posameznih ravnin
//x-y ravnina
kot=20;
	kotz=20;
	kotx=42.8;
	xkot=42.8;
	ykot=20;
	zkot=20;
function ravninaXY(){
kotx=0;
kot=0;
kotz=0;
return kotx;
	return kot;
	return kotz;
}
//x-z ravnina
function ravninaXZ(){
kotx=-90;
kot=0;
kotz=-90;
return kotx;
	return kot;
	return kotz;
}
//z-y ravnina
function ravninaZY(){
kotx=90;
kot=90;
kotz=0;
return kotx;
	return kot;
	return kotz;
}


//definiranje kota
function sprememba_kota(){
	kotx=xkot;
	kot=ykot;
	kotz=zkot;
	return kotx;
	return kot;
	return kotz;
	rotacijaNosilca();
	}


//rotacija
function rotacija(rotx,roty,rotz){
		var deg=Math.PI/180;
		spempredznakz=-rotz
		x1=rotx
		y1=(roty)*Math.cos(kotx*deg)+(spempredznakz)*Math.sin(kotx*deg);
		z1=(-(roty)*Math.sin(kotx*deg)+(spempredznakz)*Math.cos(kotx*deg));

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

		y111=y11
		x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
		z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);
return x111;
return y111;
return z111;
}
//rotacija za poljubenj kot
function rotacijaPoljubno(rotx,roty,rotz,pkotx,pkotz,pkoty){
		var deg=Math.PI/180;
		spempredznakz=-rotz
		x1=rotx
		y1=(roty)*Math.cos(pkotx*deg)+(spempredznakz)*Math.sin(pkotx*deg);
		z1=(-(roty)*Math.sin(pkotx*deg)+(spempredznakz)*Math.cos(pkotx*deg));

		z11=z1
		x11=(x1)*Math.cos(pkotz*deg)+(y1)*Math.sin(pkotz*deg);
		y11=-(x1)*Math.sin(pkotz*deg)+(y1)*Math.cos(pkotz*deg);

		y111=y11
		x111=(x11)*Math.cos(pkoty*deg)+(z11)*Math.sin(pkoty*deg);
		z111=-(x11)*Math.sin(pkoty*deg)+(z11)*Math.cos(pkoty*deg);
return x111;
return y111;
return z111;
}
//mali koordinatni sistem
function maliKoordinatniSistem(){
	mks=new Array();
	mks[0]=new Array(0.2,0,0);
	mks[1]=new Array(0,0.2,0);
	mks[2]=new Array(0,0,0.2);
	var rotiraniKSx=new Array;
	var rotiraniKSy=new Array;
	for(var i=0; i 3; i++){
		rotx=mks[i][0];
		roty=mks[i][1];
		rotz=mks[i][2];
	rotacija(rotx,roty,rotz);
	rotiraniKSx[i]=x111+0.75;
	rotiraniKSy[i]=y111+0.75;
	var tockaKS=new Array();
	tockaKS[0]=new Ppoint(0.75,0.75);
	tockaKS[1]=new Ppoint(rotiraniKSx[i],rotiraniKSy[i]);
	var maliKS=new Ppoint_list(2, tockaKS);
	 pset_line_colr_ind(2);
	 ppolyline(maliKS);
	 }
	pset_text_colr_ind(2);
	ptext(new Ppoint(rotiraniKSx[0]+0.02,rotiraniKSy[0]+0.02), "X");
	ptext(new Ppoint(rotiraniKSx[1]+0.02,rotiraniKSy[1]+0.02), "Y");
	ptext(new Ppoint(rotiraniKSx[2]+0.02,rotiraniKSy[2]+0.02), "Z");
}

//rotacija  prvo okrog x nato z in potem y
var tockax= new Array();
	var tockay= new Array();
	var tocka= new Array();

var pompodporaClenkasta=new Array();
		pompodporaClenkasta[0]=new Array(0,0,0);
		pompodporaClenkasta[1]=new Array(0.05,0,0.05);
		pompodporaClenkasta[2]=new Array(-0.05,0,0.05);
		pompodporaClenkasta[3]=new Array(0.05,0,-0.05);
		pompodporaClenkasta[4]=new Array(-0.05,0,-0.05);
		pompodporaClenkasta[5]=new Array(0.06,0,0.06);
		pompodporaClenkasta[6]=new Array(-0.06,0,0.06);
		pompodporaClenkasta[7]=new Array(0.06,0,-0.06);
		pompodporaClenkasta[8]=new Array(-0.06,0,-0.06);

function rotacijaNosilca(){
	var deg=Math.PI/180;
	
	var xx=0; yy=0; x1=0; y1=0; z1=0; x11=0; y11=0; z11=0; x111=0; y111=0; z111=0;  skal=1; skal1=1; skal11=1; skal2=1; premikx=0; premiky=0; transx=0; transy=0;
	
	transx1=0;
	transy1=0;

	for(var i=0; i n; i++){
		//alert(a[i][0]);
		 //spememba predznaka z koordinate
		spempredznakz=-a[i][2]
		x1=a[i][0]
	y1=(a[i][1])*Math.cos(kotx*deg)+(spempredznakz)*Math.sin(kotx*deg);
		z1=(-(a[i][1])*Math.sin(kotx*deg)+(spempredznakz)*Math.cos(kotx*deg));

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

		y111=y11
		x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
		z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);
	
		//translacija//
		if(y111 0){
			transy=0-y111;
			if(transy>transy1){
			transy1=transy;
			}
		}
		if(x111 0){
		transx=0-x111;
			if(transx>transx1){
			transx1=transx;
			}
		}
		tockax[i]=x111;
		tockay[i]=y111;
		//alert("xx0"+x111);
		//alert("yy0"+tockay[i]);
	}
	//skalacija
	for(var i=0; i n; i++){
		tockax[i]=tockax[i]+transx1;
		tockay[i]=tockay[i]+transy1;

		if(tockax[i]>0.98 || tockay[i]>0.98){
				skalx1=0.8/tockax[i];
				skaly1=0.8/tockay[i];
				
				if(skalx1 skaly1){
					skal1=skalx1;
				}else{
					skal1=skaly1;
				}
				if(skal1 skal){
					skal=skal1;
				}
		}
		//alert("xx1"+tockax[i]);
		//alert("yy1"+tockay[i]);
	}
		
	for(var i=0; i n; i++){
		tockax[i]=tockax[i]*skal+0.1;
		tockay[i]=tockay[i]*skal+0.1;	
		xx=tockax[i];
		yy=tockay[i];
		//alert("xx"+xx);
		//alert("yy"+yy);
		tocka[i]=new Ppoint(xx, yy)			
	}
	//risanje duplikat nosilca
	var tockaDuplikat=new Array();
	// risanje podpore
	var podporaClenkasta=new Array();
		podporaClenkasta[0]=new Array(0,0,0);
		podporaClenkasta[1]=new Array(0.05,0,0.05);
		podporaClenkasta[2]=new Array(-0.05,0,0.05);
		podporaClenkasta[3]=new Array(0.05,0,-0.05);
		podporaClenkasta[4]=new Array(-0.05,0,-0.05);
		podporaClenkasta[5]=new Array(0,0,0);
		
	
		for(var i=0; i n; i++){
			
		xxx=tockax[i]+0.001;
		yyy=tockay[i]+0.001;
		tockaDuplikat[i]=new Ppoint(xxx, yyy)	
		if(a[i][13]==1 && a[i][14]==1 && a[i][12]==1 && a[i][11]==0){
			
		var tockaPodporaClenkasta=new Array();
			for(var j=0; j 6; j++){
			rotx=podporaClenkasta[j][0]/2;
			roty=podporaClenkasta[j][1]/2;
			rotz=podporaClenkasta[j][2]/2;
			rotacija(rotx,roty,rotz);
			tockaPodporaClenkasta[j]=new Ppoint(x111+tockax[i],y111+tockay[i]);
			}
			//izris reakcij
			// v x smeri
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx;
			skoty=kot;
			skotz=kotz;
			texst="RFx1";
			color=7;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
			// v y smeri
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx-90+22.8;
			skoty=kot;
			skotz=0-90;
			texst="RFy1";
			color=7;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
			// v z smeri
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx+90;
			skoty=kot+90;
			skotz=kotz;
			texst="RFz1";
			color=7;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
		var podporac=new Ppoint_list(j, tockaPodporaClenkasta);
		pset_line_colr_ind(6);
		ppolyline(podporac);
		}
		//podpora pomicna v x smeri
	if(a[i][13]==1 && a[i][14]==1 && a[i][12]==0){
		pkotx=kotx;
		pkoty=kot;
		pkotz=kotz;
		sx=tockax[i];
		sy=tockay[i];
		podporaPomicna(pkotx,pkotz,pkoty,sx,sy);
			//reakcije v tej podpori
			// v y smeri
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx-90;
			skoty=kot;
			skotz=0-90;
			texst="RFy2";
			color=7;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
			// v z smeri
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx+90;
			skoty=kot+90;
			skotz=kotz;
			texst="RFz2";
			color=7;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
		}
	//podpora pomicna v y smeri
	if(a[i][13]==0 && a[i][14]==1 && a[i][12]==1){
		pkotx=kotx-90;
		pkoty=kot;
		pkotz=-90;
		sx=tockax[i];
		sy=tockay[i];
		podporaPomicna(pkotx,pkotz,pkoty,sx,sy);
			//reakcije v tej podpori
				// v x smeri
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx;
			skoty=kot;
			skotz=kotz;
			texst="RFx1";
			color=7;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
			// v z smeri
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx+90;
			skoty=kot+90;
			skotz=kotz;
			texst="RFz2";
			color=7;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
		}
	//podpora pomicna v z smeri
	if(a[i][13]==1 && a[i][14]==0 && a[i][12]==1){
		pkotx=kotx+90;
		pkoty=kot+90;
		pkotz=kotz;
		sx=tockax[i];
		sy=tockay[i];
		podporaPomicna(pkotx,pkotz,pkoty,sx,sy);
			//reakcije v tej podpori
				// v x smeri
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx;
			skoty=kot;
			skotz=kotz;
			texst="RFx2";
			color=7;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
			// v y smeri
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx-90;
			skoty=kot;
			skotz=0-90;
			texst="RFy2";
			color=7;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
		}
	//fiksna podpora
	
	if(a[i][13]==1 && a[i][14]==1 && a[i][12]==1 && a[i][11]==1 && a[i][10]==1){
	var podporaFiksna=new Array();
		podporaFiksna[0]=new Array(0,0.05,0.05);
		podporaFiksna[1]=new Array(0,0.05,-0.05);
		podporaFiksna[2]=new Array(0,-0.05,-0.05);
		podporaFiksna[3]=new Array(0,-0.05,0.05);
		podporaFiksna[4]=new Array(0,0.05,0.05);
		sx=tockax[i];
		sy=tockay[i];
		var tockaPodporaFiksna=new Array();
		for(var j=0; j 5; j++){
		rotx=podporaFiksna[j][0];
		roty=podporaFiksna[j][1];
		rotz=podporaFiksna[j][2];
		rotacija(rotx,roty,rotz);
		tockaPodporaFiksna[j]=new Ppoint(x111+sx,y111+sy);
		}
		var Fiksna=new Ppoint_list(j,tockaPodporaFiksna);
		pset_line_colr_ind(6);
		ppolyline(Fiksna);
		//reakcija v x smeri
		// v x smeri
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx;
			skoty=kot;
			skotz=kotz;
			texst="RFx";
			color=7;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
			// v y smeri
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx-90+22.8;
			skoty=kot;
			skotz=0-90;
			texst="RFy";
			color=7;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
			// v z smeri
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx+90;
			skoty=kot+90;
			skotz=kotz;
			texst="RFz";
			color=7;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
	}
}

var nosilec=new Ppoint_list(n, tocka);
pset_line_colr_ind(1);

ppolyline(nosilec);

var nosilec1=new Ppoint_list(n, tockaDuplikat);
pset_line_colr_ind(1);

ppolyline(nosilec1);
}

//funkcija, ki nam zagotavlja risanje aktivnih obremenitev
function risanjeAktivnihObremenitev(){
	for(var i=0; i n; i++){
		//sila v x smeri
		if(a[i][3]!=0){
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx;
			skoty=kot;
			skotz=kotz;
			texst="Fx";
			color=4;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
		}
		//sila v y smeri
		if(a[i][4]!=0){
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx-90;
			skoty=kot;
			skotz=-90;
			texst="Fy";
			color=4;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
		}
		//sila v z smeri
		if(a[i][5]!=0){
			sx=tockax[i];
			sy=tockay[i];
			skotx=kotx+90;
			skoty=kot+90;
			skotz=kotz;
			texst="Fz";
			color=4;
			izrisSile(sx,sy,skotx,skoty,skotz,texst,color);
		}
		//izris momentnih krogov okrog x
		if(a[i][6]!=0){
			sx=tockax[i];
			sy=tockay[i];
			pkotx=kotx;
			pkoty=kot;
			pkotz=kotz;
			texst="Mx";
			color=4;
			r=0.04;
		 izrisKroga(sx,sy,pkotx,pkotz,pkoty,texst,color,r)
		 }
		 //izris momentnih krogov okrog y
		if(a[i][7]!=0){
			sx=tockax[i];
			sy=tockay[i];
			pkotx=kotx-20;
			pkoty=kot-110;
			pkotz=0-265;
			texst="My";
			color=4;
			r=0.04;
		 izrisKroga(sx,sy,pkotx,pkotz,pkoty,texst,color,r)
		 }
		 //izris momentnih krogov okrog z
		if(a[i][8]!=0){
			sx=tockax[i];
			sy=tockay[i];
			pkotx=kotx+90;
			pkoty=kot+90;
			pkotz=kotz;
			texst="Mz";
			color=4;
			r=0.04;
		 izrisKroga(sx,sy,pkotx,pkotz,pkoty,texst,color,r)
		 }
	 if(i>0){
		
	if(a[i-1][15]!=0 || a[i-1][16]!=0 || a[i-1][17]!=0){
		 //izris qx zvezne obremenitve
		 if(a[i][15]!=0){
			sx1=tockax[i-1];
			sy1=tockay[i-1];
			sx=tockax[i];
			sy=tockay[i];
			pkotx=kotx;
			pkoty=kot;
			pkotz=kotz;
			texst="qx";
			color=4;
		zveznaObremenitevQ(sx,sy,color,texst,pkotx,pkotz,pkoty,sx1,sy1);
		}
		 //izris qy zvezne obremenitve
		 if(a[i][16]!=0){
			sx1=tockax[i-1];
			sy1=tockay[i-1];
			sx=tockax[i];
			sy=tockay[i];
			pkotx=kotx-90;
			pkoty=kot;
			pkotz=0-90;
			texst="qy";
			color=4;
		zveznaObremenitevQ(sx,sy,color,texst,pkotx,pkotz,pkoty,sx1,sy1);
		}
		//izris qz zvezne obremenitve
		 if(a[i][17]!=0){
			sx1=tockax[i-1];
			sy1=tockay[i-1];
			sx=tockax[i];
			sy=tockay[i];
			pkotx=kotx+90;
			pkoty=kot+90;
			pkotz=kotz;
			texst="qz";
			color=4;
		zveznaObremenitevQ(sx,sy,color,texst,pkotx,pkotz,pkoty,sx1,sy1);
		}
	}
	}
	}

}

// risanje zveznih obremenitev
function zveznaObremenitevQ(sx,sy,color,texst,pkotx,pkotz,pkoty,sx1,sy1){
	var zvezna=new Array();
		zvezna[0]=new Array(0,0,0);
		zvezna[1]=new Array(0.05,0,0);
		var zveznaObremenitev=new Array();
		for(var j=0; j 2; j++){
		rotx=zvezna[j][0];
		roty=zvezna[j][1];
		rotz=zvezna[j][2];
		rotacijaPoljubno(rotx,roty,rotz,pkotx,pkotz,pkoty);
		zveznaObremenitev[j]=new Ppoint(x111,y111);
		}
		
				var zveznaPovezava=new Array();
			zveznaPovezava[0]=new Ppoint(sx1,sy1);
			zveznaPovezava[1]=new Ppoint(zveznaObremenitev[1].x+sx1,zveznaObremenitev[1].y+sy1);
			zveznaPovezava[2]=new Ppoint(zveznaObremenitev[1].x+sx,zveznaObremenitev[1].y+sy);
			zveznaPovezava[3]=new Ppoint(sx,sy);
			var tockaZ1=new Ppoint_list(4, zveznaPovezava);
		pset_line_colr_ind(color);
		pset_text_colr_ind(color);
		ptext(new Ppoint(zveznaObremenitev[1].x+sx-0.1, zveznaObremenitev[1].y+sy+0.01), texst);
		ppolyline(tockaZ1);
	
	
}


//risanje momentnih krogov
function izrisKroga(sx,sy,pkotx,pkotz,pkoty,texst,color,r){
	var xkrog=new Array();
	var ykrog=new Array();
	var deg=Math.PI/180;	
var tockaKrog=new Array();
var tockaPuscicaKroga=new Array();
	for(var k=0; k 281; k++){
	zkroga=r*Math.cos(k*deg);
	ykroga=r*Math.sin(k*deg);
	xkroga=0;
	rotx=xkroga;
	roty=ykroga;
	rotz=zkroga;
	rotacijaPoljubno(rotx,roty,rotz,pkotx,pkotz,pkoty);
	tockaKrog[k]=new Ppoint(x111+sx,y111+sy);
	}
	var tockaS=new Ppoint_list(k, tockaKrog);
	pset_line_colr_ind(color);
	pset_text_colr_ind(color);
	ptext(new Ppoint(tockaKrog[280].x+0.03, tockaKrog[280].y+0.03), texst);
	ppolyline(tockaS);
	
	
	tockaPuscicaKroga[0]=new Ppoint(tockaKrog[280].x,tockaKrog[280].y);
	tockaPuscicaKroga[1]=new Ppoint(tockaKrog[280].x-0.001,tockaKrog[280].y+0.02);
	var tockaPuscica=new Ppoint_list(2, tockaPuscicaKroga);
	pset_line_colr_ind(color);
	ppolyline(tockaPuscica);
}


//podpora clenkasta pomicna
function podporaPomicna(pkotx,pkotz,pkoty,sx,sy){
	var tockaPomPodporaClenkasta=new Array();
			for(var j=0; j 9; j++){
			rotx=pompodporaClenkasta[j][0]/2;
			roty=pompodporaClenkasta[j][1]/2;
			rotz=pompodporaClenkasta[j][2]/2;
			rotacijaPoljubno(rotx,roty,rotz,pkotx,pkotz,pkoty)
			tockaPomPodporaClenkasta[j]=new Ppoint(x111+sx,y111+sy);
			}
			
			var podporab=new Ppoint_list(6, tockaPomPodporaClenkasta);
			pset_line_colr_ind(6);
			ppolyline(podporab);
			var crtaPodpora1=new Array();
				crtaPodpora1[0]=new Ppoint(tockaPomPodporaClenkasta[5].x,tockaPomPodporaClenkasta[5].y);
				crtaPodpora1[1]=new Ppoint(tockaPomPodporaClenkasta[6].x,tockaPomPodporaClenkasta[6].y);
			var podporab1=new Ppoint_list(2, crtaPodpora1);
			pset_line_colr_ind(6);
			ppolyline(podporab1);
			var crtaPodpora2=new Array();
				crtaPodpora2[0]=new Ppoint(tockaPomPodporaClenkasta[7].x,tockaPomPodporaClenkasta[7].y);
				crtaPodpora2[1]=new Ppoint(tockaPomPodporaClenkasta[8].x,tockaPomPodporaClenkasta[8].y);
			var podporab2=new Ppoint_list(2, crtaPodpora2);
			pset_line_colr_ind(6);
			ppolyline(podporab2);
}
//izris sil v x smeri
function izrisSile(sx,sy,skotx,skoty,skotz,texst,color){
var sila=new Array();
	sila[0]=new Array(0,0,0);
	sila[1]=new Array(0.1,0,0);
	sila[2]=new Array(0.08,0,0.005);
	sila[3]=new Array(0.08,0,-0.005);
	sila[4]=new Array(0.1,0,0);
	
var tockaSila=new Array();
	for(var k=0; k 5; k++){
	rotx=sila[k][0];
	roty=sila[k][1];
	rotz=sila[k][2];
	pkotx=skotx;
	pkoty=skoty;
	pkotz=skotz;
	rotacijaPoljubno(rotx,roty,rotz,pkotx,pkotz,pkoty);
	tockaSila[k]=new Ppoint(x111+sx,y111+sy);
	}
	var tockaS=new Ppoint_list(k, tockaSila);
	pset_line_colr_ind(color);
	pset_text_colr_ind(color);
	ptext(new Ppoint(tockaSila[4].x+0.002, tockaSila[4].y+0.002), texst);
	ppolyline(tockaS);
}


//izris krogov za momente//
function moment_krog(){
var xr=0; yr=0; beta=0;
var deg=Math.PI/180;
//izris z kroga
radij=0.05;
x0=0.25;
y0=0.4;
zr=0;

var krog=new Array();
	for(var k=0; k 280; k++){
		xr=radij*Math.cos(k*deg)+x0;
		yr=radij*Math.sin(k*deg)+y0;
		//se rotacija okrog x in y osi

		x1=xr
			y1=(yr)*Math.cos(kotx*deg)+(zr)*Math.sin(kotx*deg);
			z1=(-yr)*Math.sin(kotx*deg)+(zr)*Math.cos(kotx*deg);

			
			y111=y1
			x111=(x1)*Math.cos(kot*deg)+(z1)*Math.sin(kot*deg);
			z111=-(x1)*Math.sin(kot*deg)+(z1)*Math.cos(kot*deg);
			//alert("x"+x111);
			//alert("y"+y111);
			krog[k]=new Ppoint(x111, y111);
			
		}
var puscica=new Array
      puscica[0]=new Ppoint(krog[0].x, krog[0].y);
	  puscica[1]=new Ppoint(krog[0].x-0.003, krog[0].y+0.025);
	   puscica[2]=new Ppoint(krog[0].x, krog[0].y);
	  puscica[3]=new Ppoint(krog[0].x-0.02, krog[0].y+0.004);
var moment_puscica=new Ppoint_list(4, puscica);
		pset_line_colr_ind(5);
		 pset_text_colr_ind(5);
 ptext(new Ppoint(krog[0].x-0.01, krog[0].y+0.04), "Mz");
		ppolyline(moment_puscica);

	var moment_krog=new Ppoint_list(k, krog);
		pset_line_colr_ind(5);

		ppolyline(moment_krog);
//za y os
var krogy=new Array();
radij=0.05;
x0=0.018;
yr=0.8;
z0=0.3;

for(var k=0; k 280; k++){
		xr=radij*Math.cos(k*deg)+x0;
		zr=radij*Math.sin(k*deg)+y0;
		//se rotacija okrog x in y osi

		x1=xr
			y1=(yr)*Math.cos(kotx*deg)+(zr)*Math.sin(kotx*deg);
			z1=(-yr)*Math.sin(kotx*deg)+(zr)*Math.cos(kotx*deg);

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

			
			//alert("x"+x111);
			//alert("y"+y111);
			krogy[k]=new Ppoint(x11, y11);
			
		}
	var moment_krogy=new Ppoint_list(k, krogy);
		pset_line_colr_ind(5);

		ppolyline(moment_krogy);

	var puscicay=new Array
      puscicay[0]=new Ppoint(krogy[0].x, krogy[0].y);
	  puscicay[1]=new Ppoint(krogy[0].x+0.008, krogy[0].y+0.02);
	   puscicay[2]=new Ppoint(krogy[0].x, krogy[0].y);
	  puscicay[3]=new Ppoint(krogy[0].x-0.015, krogy[0].y+0.009);
var moment_puscicay=new Ppoint_list(4, puscicay);
		pset_line_colr_ind(5);
		 pset_text_colr_ind(5);
 ptext(new Ppoint(krogy[0].x-0.01, krogy[0].y+0.04), "My");
		ppolyline(moment_puscicay);

//za x os
var krogx=new Array();
radij=0.05;
xr=0.75;
y0=0.566;
z0=0.4;

for(var k=0; k 280; k++){
		zr=radij*Math.cos(k*deg)+x0;
		yr=radij*Math.sin(k*deg)+y0;
		//se rotacija okrog x in y osi

		

		z11=zr
		x11=(xr)*Math.cos(kotz*deg)+(yr)*Math.sin(kotz*deg);
		y11=-(xr)*Math.sin(kotz*deg)+(yr)*Math.cos(kotz*deg);

		y111=y11
			x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
			z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);	
			//alert("x"+x111);
			//alert("y"+y111);
			krogx[k]=new Ppoint(x111, y111);
			
		}
	var moment_krogx=new Ppoint_list(k, krogx);
		pset_line_colr_ind(5);

		ppolyline(moment_krogx);

	var puscicax=new Array
      puscicax[0]=new Ppoint(krogx[0].x, krogx[0].y);
	  puscicax[1]=new Ppoint(krogx[0].x+0.01, krogx[0].y+0.02);
	   puscicax[2]=new Ppoint(krogx[0].x, krogx[0].y);
	  puscicax[3]=new Ppoint(krogx[0].x-0.01, krogx[0].y+0.01);
var moment_puscicax=new Ppoint_list(4, puscicax);
		pset_line_colr_ind(5);
		 pset_text_colr_ind(5);
 ptext(new Ppoint(krogx[0].x+0.01, krogx[0].y+0.04), "Mx");
		ppolyline(moment_puscicax);

}



function main()
{ 
	var deg=Math.PI/180;
  var WorkstnID = 1;                 /* workstation identifier */
  var ConnID = document.Phigs;       /* connection identifier */
  var WorkstnType = PWODSX;          /* An OUTPUT, direct, single, Xwindow */
  var TheLine = 1;  /* structure ID (chosen by user) */
  var LinePts = new Array();         /* points for the polyline */
      LinePts[0] = new Ppoint(0.0, 0.0);
      LinePts[1] = new Ppoint(0.0, 0.0);
	 
  var LineData  = new Ppoint_list(2, LinePts); /* data for the polyline */
 
  popen_phigs("stderr", 0);             /* errors go to "stderr" */
  popen_ws(WorkstnID, ConnID, WorkstnType);
  popen_struct(TheLine);
  ppolyline(LineData);
  koordinat();
  koordinat1();
  rotacijaNosilca();
  risanjeAktivnihObremenitev();
  moment_krog();
  pclose_struct();
  ppost_struct(WorkstnID, TheLine, 1.0);
  pclose_ws(WorkstnID);
  pclose_phigs();           

}
	
//izrus diagrama 
var tockaN=new Array();
var tockaN1=new Array();
var tockaxN=new Array;
	var tockayN=new Array;
	var tockaxN1=new Array;
	var tockayN1=new Array;
	var tockaxTz=new Array;
	var tockayTz=new Array;
	var tockaxTz1=new Array;
	var tockaTz=new Array;
	var tockaTz1=new Array;
	var tockayTz1=new Array;
	var tockaxTy=new Array;
	var tockayTy=new Array;
	var tockaxTy1=new Array;
	var tockaTy=new Array;
	var tockaTy1=new Array;
	var tockayTy1=new Array;
var tockaMx=new Array();
var tockaMx1=new Array();
var tockaxMx=new Array;
	var tockayMx=new Array;
	var tockaxMx1=new Array;
	var tockayMx1=new Array;
	var tockaMy=new Array();
var tockaMy1=new Array();
var tockaxMy=new Array;
	var tockayMy=new Array;
	var tockaxMy1=new Array;
	var tockayMy1=new Array;
	var tockaMz=new Array();
var tockaMz1=new Array();
var tockaxMz=new Array;
	var tockayMz=new Array;
	var tockaxMz1=new Array;
	var tockayMz1=new Array;
function izris_diagramov(){
var deg=Math.PI/180;
//skalacija
velikostDiagrama=0.1/Math.abs(skal);
var skalN=1;
var skalTz=1;
var skalTy=1;
var skalMx=1;
var skalMy=1;
var skalMz=1;

	for(var i=0; i n; i++){
		skalN0=Math.abs(N[i])/velikostDiagrama;
		skalN1=Math.abs(N1[i])/velikostDiagrama;
			if(skalN0>skalN1){
				skalNy=skalN0;
			}else{
				skalNy=skalN1;
			}
			if(skalNy>skalN){
				skalN=skalNy;
			}
		skalTz0=Math.abs(Tz[i])/velikostDiagrama;
		skalTz1=Math.abs(Tz1[i])/velikostDiagrama;
			if(skalTz0>skalTz1){
				skalTzy=skalTz0;
			}else{
				skalTzy=skalTz1;
			}
			if(skalTzy>skalTz){
				skalTz=skalTzy;
			}
		skalTy0=Math.abs(Ty[i])/velikostDiagrama;
		skalTy1=Math.abs(Ty1[i])/velikostDiagrama;
			if(skalTy0>skalTy1){
				skalTyy=skalTy0;
			}else{
				skalTyy=skalTy1;
			}
			if(skalTyy>skalTy){
				skalTy=skalTyy;
			}
		skalMx0=Math.abs(Mox[i])/velikostDiagrama;
		skalMx1=Math.abs(Mox1[i])/velikostDiagrama;
			if(skalMx0>skalMx1){
				skalMxy=skalMx0;
			}else{
				skalMxy=skalMx1;
			}
			if(skalMxy>skalMx){
				skalMx=skalMxy;
			}
			skalMy0=Math.abs(Moy[i])/velikostDiagrama;
		skalMy1=Math.abs(Moy1[i])/velikostDiagrama;
			if(skalMy0>skalMy1){
				skalMyy=skalMy0;
			}else{
				skalMyy=skalMy1;
			}
			if(skalMyy>skalMy){
				skalMy=skalMyy;
			}
				skalMz0=Math.abs(Moz[i])/velikostDiagrama;
		skalMz1=Math.abs(Moz1[i])/velikostDiagrama;
			if(skalMz0>skalMz1){
				skalMzy=skalMz0;
			}else{
				skalMzy=skalMz1;
			}
			if(skalMzy>skalMz){
				skalMz=skalMzy;
			}
	}
	for(var i=0; i n; i++){
	tockaN[i]=new Array();
	tockaN1[i]=new Array();
	tockaTz[i]=new Array();
	tockaTz1[i]=new Array();
	tockaTy[i]=new Array();
	tockaTy1[i]=new Array();
	tockaMx[i]=new Array();
	tockaMx1[i]=new Array();
	tockaMy[i]=new Array();
	tockaMy1[i]=new Array();
	tockaMz[i]=new Array();
	tockaMz1[i]=new Array();
	
		for(var j=0; j 3; j++){
		tockaN[i][j]=((N[i]/skalN)/rrb[i])*bb[i][j]+a[i][j];
		tockaN1[i][j]=((N1[i]/skalN)/rrb1[i])*bb1[i][j]+a[i][j];
		tockaTz[i][j]=((Tz[i]/skalTz)/rrc[i])*cc[i][j]+a[i][j];
		tockaTz1[i][j]=((Tz1[i]/skalTz)/rrc1[i])*cc1[i][j]+a[i][j];
		tockaTy[i][j]=((Ty[i]/skalTy)/rrb[i])*bb[i][j]+a[i][j];
		tockaTy1[i][j]=((Ty1[i]/skalTy)/rrb1[i])*bb1[i][j]+a[i][j];
		tockaMx[i][j]=((Mox[i]/skalMx)/rrb[i])*bb[i][j]+a[i][j];
		tockaMx1[i][j]=((Mox1[i]/skalMx)/rrb1[i])*bb1[i][j]+a[i][j];
		tockaMy[i][j]=((Moy[i]/skalMy)/rrb[i])*bb[i][j]+a[i][j];
		tockaMy1[i][j]=((Moy1[i]/skalMy)/rrb1[i])*bb1[i][j]+a[i][j];
		tockaMz[i][j]=((Moz[i]/skalMz)/rrc[i])*cc[i][j]+a[i][j];
		tockaMz1[i][j]=((Moz1[i]/skalMz)/rrc1[i])*cc1[i][j]+a[i][j];
		}
	}
//rotacija //
		
	for(var i=0; i n; i++){
		//alert(a[i][0]);
		 //spememba predznaka z koordinate
		 //za N
		spempredznakz=-tockaN[i][2]
		x1=tockaN[i][0]
		y1=(tockaN[i][1])*Math.cos(kotx*deg)+(spempredznakz)*Math.sin(kotx*deg);
		z1=(-(tockaN[i][1])*Math.sin(kotx*deg)+(spempredznakz)*Math.cos(kotx*deg));

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

		y111=y11
		x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
		z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);
	
	tockaxN[i]=(x111+transx1)*skal+0.1;
	tockayN[i]=(y111+transy1)*skal+0.1;
		// za N1
	spempredznakz=-tockaN1[i][2]
		x1=tockaN1[i][0]
		y1=(tockaN1[i][1])*Math.cos(kotx*deg)+(spempredznakz)*Math.sin(kotx*deg);
		z1=(-(tockaN1[i][1])*Math.sin(kotx*deg)+(spempredznakz)*Math.cos(kotx*deg));

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

		y111=y11
		x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
		z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);

	tockaxN1[i]=(x111+transx1)*skal+0.1;
	tockayN1[i]=(y111+transy1)*skal+0.1;
	
	//za Tz
	spempredznakz=-tockaTz[i][2]
		x1=tockaTz[i][0]
		y1=(tockaTz[i][1])*Math.cos(kotx*deg)+(spempredznakz)*Math.sin(kotx*deg);
		z1=(-(tockaTz[i][1])*Math.sin(kotx*deg)+(spempredznakz)*Math.cos(kotx*deg));

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

		y111=y11
		x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
		z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);
	
	tockaxTz[i]=(x111+transx1)*skal+0.1;
	tockayTz[i]=(y111+transy1)*skal+0.1;
		// za Tz1
	spempredznakz=-tockaTz1[i][2]
		x1=tockaTz1[i][0]
		y1=(tockaTz1[i][1])*Math.cos(kotx*deg)+(spempredznakz)*Math.sin(kotx*deg);
		z1=(-(tockaTz1[i][1])*Math.sin(kotx*deg)+(spempredznakz)*Math.cos(kotx*deg));

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

		y111=y11
		x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
		z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);

	tockaxTz1[i]=(x111+transx1)*skal+0.1;
	tockayTz1[i]=(y111+transy1)*skal+0.1;

	//za Ty
	spempredznakz=-tockaTy[i][2]
		x1=tockaTy[i][0]
		y1=(tockaTy[i][1])*Math.cos(kotx*deg)+(spempredznakz)*Math.sin(kotx*deg);
		z1=(-(tockaTy[i][1])*Math.sin(kotx*deg)+(spempredznakz)*Math.cos(kotx*deg));

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

		y111=y11
		x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
		z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);
	
	tockaxTy[i]=(x111+transx1)*skal+0.1;
	tockayTy[i]=(y111+transy1)*skal+0.1;
		// za Ty1
	spempredznakz=-tockaTy1[i][2]
		x1=tockaTy1[i][0]
		y1=(tockaTy1[i][1])*Math.cos(kotx*deg)+(spempredznakz)*Math.sin(kotx*deg);
		z1=(-(tockaTy1[i][1])*Math.sin(kotx*deg)+(spempredznakz)*Math.cos(kotx*deg));

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

		y111=y11
		x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
		z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);

	tockaxTy1[i]=(x111+transx1)*skal+0.1;
	tockayTy1[i]=(y111+transy1)*skal+0.1;
	
	
	//za Mx
	spempredznakz=-tockaMx[i][2]
		x1=tockaMx[i][0]
		y1=(tockaMx[i][1])*Math.cos(kotx*deg)+(spempredznakz)*Math.sin(kotx*deg);
		z1=(-(tockaMx[i][1])*Math.sin(kotx*deg)+(spempredznakz)*Math.cos(kotx*deg));

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

		y111=y11
		x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
		z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);
	
	tockaxMx[i]=(x111+transx1)*skal+0.1;
	tockayMx[i]=(y111+transy1)*skal+0.1;
		// za Mx1
	spempredznakz=-tockaMx1[i][2]
		x1=tockaMx1[i][0]
		y1=(tockaMx1[i][1])*Math.cos(kotx*deg)+(spempredznakz)*Math.sin(kotx*deg);
		z1=(-(tockaMx1[i][1])*Math.sin(kotx*deg)+(spempredznakz)*Math.cos(kotx*deg));

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

		y111=y11
		x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
		z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);

	tockaxMx1[i]=(x111+transx1)*skal+0.1;
	tockayMx1[i]=(y111+transy1)*skal+0.1;
	
	//za My
	spempredznakz=-tockaMy[i][2]
		x1=tockaMy[i][0]
		y1=(tockaMy[i][1])*Math.cos(kotx*deg)+(spempredznakz)*Math.sin(kotx*deg);
		z1=(-(tockaMy[i][1])*Math.sin(kotx*deg)+(spempredznakz)*Math.cos(kotx*deg));

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

		y111=y11
		x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
		z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);
	
	tockaxMy[i]=(x111+transx1)*skal+0.1;
	tockayMy[i]=(y111+transy1)*skal+0.1;
		// za My1
	spempredznakz=-tockaMy1[i][2]
		x1=tockaMy1[i][0]
		y1=(tockaMy1[i][1])*Math.cos(kotx*deg)+(spempredznakz)*Math.sin(kotx*deg);
		z1=(-(tockaMy1[i][1])*Math.sin(kotx*deg)+(spempredznakz)*Math.cos(kotx*deg));

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

		y111=y11
		x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
		z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);

	tockaxMy1[i]=(x111+transx1)*skal+0.1;
	tockayMy1[i]=(y111+transy1)*skal+0.1;

	//za Mz
	spempredznakz=-tockaMz[i][2]
		x1=tockaMz[i][0]
		y1=(tockaMz[i][1])*Math.cos(kotx*deg)+(spempredznakz)*Math.sin(kotx*deg);
		z1=(-(tockaMz[i][1])*Math.sin(kotx*deg)+(spempredznakz)*Math.cos(kotx*deg));

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

		y111=y11
		x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
		z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);
	
	tockaxMz[i]=(x111+transx1)*skal+0.1;
	tockayMz[i]=(y111+transy1)*skal+0.1;
		// za Mz1
	spempredznakz=-tockaMz1[i][2]
		x1=tockaMz1[i][0]
		y1=(tockaMz1[i][1])*Math.cos(kotx*deg)+(spempredznakz)*Math.sin(kotx*deg);
		z1=(-(tockaMz1[i][1])*Math.sin(kotx*deg)+(spempredznakz)*Math.cos(kotx*deg));

		z11=z1
		x11=(x1)*Math.cos(kotz*deg)+(y1)*Math.sin(kotz*deg);
		y11=-(x1)*Math.sin(kotz*deg)+(y1)*Math.cos(kotz*deg);

		y111=y11
		x111=(x11)*Math.cos(kot*deg)+(z11)*Math.sin(kot*deg);
		z111=-(x11)*Math.sin(kot*deg)+(z11)*Math.cos(kot*deg);

	tockaxMz1[i]=(x111+transx1)*skal+0.1;
	tockayMz1[i]=(y111+transy1)*skal+0.1;
	}
}
	//zspis v tocko

function osne_sile(){
	for(var i=0; i n-1; i++){
	var lineN=new Array;
	lineN[0]=new Ppoint(tocka[i].x, tocka[i].y);
	lineN[1]=new Ppoint(tockaxN[i], tockayN[i]);
	lineN[2]=new Ppoint(tockaxN1[i+1], tockayN1[i+1]);
	lineN[3]=new Ppoint(tocka[i+1].x, tocka[i+1].y);
	lineN[4]=new Ppoint(lineN[1].x, lineN[1].y);
	lineN[5]=new Ppoint(tocka[i].x, tocka[i].y);
	lineN[6]=new Ppoint(lineN[2].x, lineN[2].y);
	
	var sila_osna=new Ppoint_list(7, lineN);
		pset_line_colr_ind(3);
			 pset_text_colr_ind(3);
 ptext(new Ppoint(tockaxN[i]+0.03, tockayN[i]+0.02), N[i]);
 ptext(new Ppoint(tockaxN1[i+1]-0.03, tockayN1[i+1]+0.02), N1[i+1]);
		ppolyline(sila_osna);
	}

}

//odpre phigs za izris diagramov
function main_diagrami_osne_sile()
{ 
	var deg=Math.PI/180;
  var WorkstnID = 1;                 /* workstation identifier */
  var ConnID = document.Phigs;       /* connection identifier */
  var WorkstnType = PWODSX;          /* An OUTPUT, direct, single, Xwindow */
  var TheLine = 1;  /* structure ID (chosen by user) */
  
 
  popen_phigs("stderr", 0);             /* errors go to "stderr" */
  popen_ws(WorkstnID, ConnID, WorkstnType);
  popen_struct(TheLine);
   rotacijaNosilca();
  maliKoordinatniSistem();
  izris_diagramov();
  osne_sile();
  pclose_struct();
  ppost_struct(WorkstnID, TheLine, 1.0);
  pclose_ws(WorkstnID);
  pclose_phigs();           
}


	//zspis v tocko

function precne_z(){
	for(var i=0; i n-1; i++){
	var lineN=new Array;
	lineN[0]=new Ppoint(tocka[i].x, tocka[i].y);
	lineN[1]=new Ppoint(tockaxTz[i], tockayTz[i]);
	lineN[2]=new Ppoint(tockaxTz1[i+1], tockayTz1[i+1]);
	lineN[3]=new Ppoint(tocka[i+1].x, tocka[i+1].y);
	lineN[4]=new Ppoint(lineN[1].x, lineN[1].y);
	lineN[5]=new Ppoint(tocka[i].x, tocka[i].y);
	lineN[6]=new Ppoint(lineN[2].x, lineN[2].y);
	
	var sila_precna_z=new Ppoint_list(7, lineN);
		pset_line_colr_ind(3);
			 pset_text_colr_ind(3);
 ptext(new Ppoint(tockaxTz[i]+0.04, tockayTz[i]+0.02), Tz[i]);
 ptext(new Ppoint(tockaxTz1[i+1]-0.04, tockayTz1[i+1]+0.02), Tz1[i+1]);
		ppolyline(sila_precna_z);
	}

}

//odpre phigs za izris diagramov
function main_diagrami_precne_z()
{ 
	var deg=Math.PI/180;
  var WorkstnID = 1;                 /* workstation identifier */
  var ConnID = document.Phigs;       /* connection identifier */
  var WorkstnType = PWODSX;          /* An OUTPUT, direct, single, Xwindow */
  var TheLine = 1;  /* structure ID (chosen by user) */
  
 
  popen_phigs("stderr", 0);             /* errors go to "stderr" */
  popen_ws(WorkstnID, ConnID, WorkstnType);
  popen_struct(TheLine);
  maliKoordinatniSistem();
  rotacijaNosilca();
  izris_diagramov();
  precne_z();
  pclose_struct();
  ppost_struct(WorkstnID, TheLine, 1.0);
  pclose_ws(WorkstnID);
  pclose_phigs();           

}

	//zspis v tocko

function precne_y(){
	for(var i=0; i n-1; i++){
	var lineN=new Array;
	lineN[0]=new Ppoint(tocka[i].x, tocka[i].y);
	lineN[1]=new Ppoint(tockaxTy[i], tockayTy[i]);
	lineN[2]=new Ppoint(tockaxTy1[i+1], tockayTy1[i+1]);
	lineN[3]=new Ppoint(tocka[i+1].x, tocka[i+1].y);
	lineN[4]=new Ppoint(lineN[1].x, lineN[1].y);
	lineN[5]=new Ppoint(tocka[i].x, tocka[i].y);
	lineN[6]=new Ppoint(lineN[2].x, lineN[2].y);
	
	var sila_precna_y=new Ppoint_list(7, lineN);
		pset_line_colr_ind(3);
			 pset_text_colr_ind(3);
 ptext(new Ppoint(tockaxTy[i]+0.03, tockayTy[i]+0.02), Ty[i]);
 ptext(new Ppoint(tockaxTy1[i+1]-0.03, tockayTy1[i+1]+0.02), Ty1[i+1]);
		ppolyline(sila_precna_y);
	}

}

//odpre phigs za izris diagramov
function main_diagrami_precne_y()
{ 
	var deg=Math.PI/180;
  var WorkstnID = 1;                 /* workstation identifier */
  var ConnID = document.Phigs;       /* connection identifier */
  var WorkstnType = PWODSX;          /* An OUTPUT, direct, single, Xwindow */
  var TheLine = 1;  /* structure ID (chosen by user) */
  
 
  popen_phigs("stderr", 0);             /* errors go to "stderr" */
  popen_ws(WorkstnID, ConnID, WorkstnType);
  popen_struct(TheLine);
   maliKoordinatniSistem();
  rotacijaNosilca();
  izris_diagramov();
  precne_y();
  pclose_struct();
  ppost_struct(WorkstnID, TheLine, 1.0);
  pclose_ws(WorkstnID);
  pclose_phigs();           

}

	//zspis v tocko

function moment_x(){
	for(var i=0; i n-1; i++){
	var lineN=new Array;
	lineN[0]=new Ppoint(tocka[i].x, tocka[i].y);
	lineN[1]=new Ppoint(tockaxMx[i], tockayMx[i]);
	lineN[2]=new Ppoint(tockaxMx1[i+1], tockayMx1[i+1]);
	lineN[3]=new Ppoint(tocka[i+1].x, tocka[i+1].y);
		
	var moment_x=new Ppoint_list(4, lineN);
		pset_line_colr_ind(3);
			 pset_text_colr_ind(3);
 ptext(new Ppoint(tockaxMx[i]+0.03, tockayMx[i]+0.02), Mox[i]);
 ptext(new Ppoint(tockaxMx1[i+1]-0.03, tockayMx1[i+1]+0.02), Mox1[i+1]);
		ppolyline(moment_x);
	}

}

//odpre phigs za izris diagramov
function main_diagrami_moment_x()
{ 
	var deg=Math.PI/180;
  var WorkstnID = 1;                 /* workstation identifier */
  var ConnID = document.Phigs;       /* connection identifier */
  var WorkstnType = PWODSX;          /* An OUTPUT, direct, single, Xwindow */
  var TheLine = 1;  /* structure ID (chosen by user) */
  
 
  popen_phigs("stderr", 0);             /* errors go to "stderr" */
  popen_ws(WorkstnID, ConnID, WorkstnType);
  popen_struct(TheLine);
  maliKoordinatniSistem();
  rotacijaNosilca();
  izris_diagramov();
  moment_x();
  pclose_struct();
  ppost_struct(WorkstnID, TheLine, 1.0);
  pclose_ws(WorkstnID);
  pclose_phigs();           

}

function moment_y(){
	for(var i=0; i n-1; i++){
	var lineN=new Array;
	lineN[0]=new Ppoint(tocka[i].x, tocka[i].y);
	lineN[1]=new Ppoint(tockaxMy[i], tockayMy[i]);
	lineN[2]=new Ppoint(tockaxMy1[i+1], tockayMy1[i+1]);
	lineN[3]=new Ppoint(tocka[i+1].x, tocka[i+1].y);
	var moment_y=new Ppoint_list(4, lineN);
		pset_line_colr_ind(3);
			 pset_text_colr_ind(3);
 ptext(new Ppoint(tockaxMy[i]+0.03, tockayMy[i]+0.02), Moy[i]);
 ptext(new Ppoint(tockaxMy1[i+1]-0.03, tockayMy1[i+1]+0.02), Moy1[i+1]);
		ppolyline(moment_y);
	}

}

//odpre phigs za izris diagramov
function main_diagrami_moment_y()
{ 
	var deg=Math.PI/180;
  var WorkstnID = 1;                 /* workstation identifier */
  var ConnID = document.Phigs;       /* connection identifier */
  var WorkstnType = PWODSX;          /* An OUTPUT, direct, single, Xwindow */
  var TheLine = 1;  /* structure ID (chosen by user) */
  
 
  popen_phigs("stderr", 0);             /* errors go to "stderr" */
  popen_ws(WorkstnID, ConnID, WorkstnType);
  popen_struct(TheLine);
  maliKoordinatniSistem();
  rotacijaNosilca();
  izris_diagramov();
  moment_y();
  pclose_struct();
  ppost_struct(WorkstnID, TheLine, 1.0);
  pclose_ws(WorkstnID);
  pclose_phigs();           

}

function moment_z(){
	for(var i=0; i n-1; i++){
	var lineN=new Array;
	lineN[0]=new Ppoint(tocka[i].x, tocka[i].y);
	lineN[1]=new Ppoint(tockaxMz[i], tockayMz[i]);
	lineN[2]=new Ppoint(tockaxMz1[i+1], tockayMz1[i+1]);
	lineN[3]=new Ppoint(tocka[i+1].x, tocka[i+1].y);
	var moment_z=new Ppoint_list(4, lineN);
		pset_line_colr_ind(3);
			 pset_text_colr_ind(3);
 ptext(new Ppoint(tockaxMz[i]+0.04, tockayMz[i]+0.02), Moz[i]);
 ptext(new Ppoint(tockaxMz1[i+1]-0.04, tockayMz1[i+1]+0.02), Moz1[i+1]);
		ppolyline(moment_z);
	}

}

//odpre phigs za izris diagramov
function main_diagrami_moment_z()
{ 
	var deg=Math.PI/180;
  var WorkstnID = 1;                 /* workstation identifier */
  var ConnID = document.Phigs;       /* connection identifier */
  var WorkstnType = PWODSX;          /* An OUTPUT, direct, single, Xwindow */
  var TheLine = 1;  /* structure ID (chosen by user) */
  
 
  popen_phigs("stderr", 0);             /* errors go to "stderr" */
  popen_ws(WorkstnID, ConnID, WorkstnType);
  popen_struct(TheLine);
 maliKoordinatniSistem();
  rotacijaNosilca();
  izris_diagramov();
  moment_z();
  pclose_struct();
  ppost_struct(WorkstnID, TheLine, 1.0);
  pclose_ws(WorkstnID);
  pclose_phigs();           

}

//izpis rezultatov v okno
function zapisText()
{
  
  okno = open("", "Rezultati", // novo okno
        "width=600,height=200,menubar=yes,scrollbars=yes");
  okno.creator = self;
okno.document.open("text/plain");
  rez=okno.document
  rez.write("Rezultati izracuna:\n");
rez.write("Reakcije:\n");
if(b==1){
		rez.write("Rezultati reakcij v podpori :\n\ Rfx="+rfx+";  Rfy="+rfy+";  Rfz="+rfz+";\n\ Rmx="+rmx+";  Rmy="+rmy+";  Rmz="+rmz+";\n");
	}else{
		rez.write("Rezultati reakcij v fiksni podpori :\n\ Rfx1="+rfx1a+"; Rfy1="+rfy1a+"; Rfz1="+rfz1a+";\n Rezultati reakcij v pomicni podpori :\n\ Rfx2="+rfx2b+"; Rfy2="+rfy2b+"; Rfz2="+rfz2b+";\n");
	}
rez.write("Notranje velicine:\n");
  for (var r= 0 ; r< n ; r++)
    {
	rez.write("Tocka:("+a[r][0]+","+a[r][1]+","+a[r][2]+"); N1="+N1[r]+"; N="+N[r]+"; Ty1="+Ty1[r]+"; Ty="+Ty[r]+"; Tz1="+Tz1[r]+"; Tz="+Tz[r]+"; Mx1="+Mox1[r]+"; Mx="+Mox[r]+"; My1="+Moy1[r]+"; My="+Moy[r]+"; Mz1="+Moz1[r]+"; Mz="+Moz[r]+"\n")
  
  }
  okno.document.close();  
}




Janez Benedicic