id='PESAS' matriz='sí' evaluar='una-sola-vez' columnas='6' filas='300' expresión='X=0 //coordenada x;Y=1 //coordenada y;W=2 //ancho;TIPO=3 //tipo de pesa, &squot;1&squot; &squot;x&squot;;LADO=4 //posición de la pesa;VISIBLE=5 //determina si la pesa es visible o no;;//constantes para denotar el lado donde se encuentra una pesa;L_CEN=0 //en el centro;L_IZQ=1 //lado izquierdo;L_DER=2 //lado derecho;L_POL_IZQ=3 // en la polea izquierda;L_POL_DER=4 // en la polea derecha' tipo='matriz' info='Matriz para guardar la información de las pesas' 
id='initPesas()' algoritmo='sí' expresión='0' local='i;cond' inicio='i=0' hacer='cond=(i < PESAS.filas/2);PESAS[i,X]=balanza.x;PESAS[i,Y]=balanza.y -((cond)?pesaUno.y:pesaX.y);PESAS[i,W]=(cond)?pesaUno.w:pesaX.w;PESAS[i,TIPO]=(cond)?&squot;1&squot;:&squot;x&squot;;PESAS[i,LADO]=L_CEN;PESAS[i,VISIBLE]=1;;i=i+1' mientras='i<PESAS.filas' tipo='función' info='Inicia los valores de las pesas' 
id='radianes(x)' algoritmo='no' expresión='pi*x/180' tipo='función' info='Convierte de grados a radianes' 
id='grados(x)' algoritmo='no' expresión='x*180/pi' tipo='función' info='Convierte de radianes a grados' 
id='selecciona(x,y)' algoritmo='sí' expresión='cual' local='cual;px;py;pw;ph;cond' inicio='i=0;cond=0' hacer='pw=PESAS[i,W];ph=pw;px=PESAS[i,X]-pw/2;py=PESAS[i,Y]-ph/2;;cond=(PESAS[i,VISIBLE])&&(px<=x)&&(x<=(px+pw))&&(py<=y)&&(y<=(py+ph));cual=(cond)?i:-1;(cond)?obtenerDesface(cual):NULL;;i=i+1' mientras='(cond==0)&&(i<PESAS.filas)' tipo='función' info='Encuenta el indice de la una pesa seleccionada con el mouse' 
id='obtenerDesface(cual)' algoritmo='sí' expresión='0' hacer='pesas_offset_x=PESAS[cual,X]-E1.mouse_x;pesas_offset_y=PESAS[cual,Y]+E1.mouse_y' tipo='función' info='Obtiene el desface entre la posición del click y la posicion de la pesa' 
id='arrastraPesa(cual)' algoritmo='sí' expresión='0' hacer='PESAS[cual,X]= E1.mouse_x+pesas_offset_x;PESAS[cual,Y]=-E1.mouse_y+pesas_offset_y' tipo='función' info='Cambia las coordenadas de la pesa ' 
id='colocaPesa(cual)' algoritmo='sí' expresión='0' hacer='PESAS[cual,LADO]=obtenerLado(cual);acomodaPesas()' tipo='función' info='Coloca una pesa en su lugar' 
id='obtenerLado(cual)' algoritmo='sí' expresión='lado' local='lado;pPoleaIzq.x;pPoleaDer.x;pw2' inicio='lado=L_CEN' hacer='pw2=plato.w/2;;//plato izquierdo;lado=((platoIzq.x-pw2 < PESAS[cual,X])&&(PESAS[cual,X] < platoIzq.x+pw2))?L_IZQ:lado;;//plato derecho;lado=((platoDer.x-pw2 < PESAS[cual,X])&&(PESAS[cual,X] < platoDer.x+pw2))?L_DER:lado;;//plato polea izquierda;pPoleaIzq.x=balanza.x-brazo.w-polea.sep*escalaImg;lado=((pPoleaIzq.x-pw2 < PESAS[cual,X])&&(PESAS[cual,X] < pPoleaIzq.x+pw2))?L_POL_IZQ:lado;;//plato polea derecha;pPoleaDer.x=balanza.x+brazo.w+polea.sep*escalaImg;lado=((pPoleaDer.x-pw2 < PESAS[cual,X])&&(PESAS[cual,X] < pPoleaDer.x+pw2))?L_POL_DER:lado;' tipo='función' info='Determina en que lado se soltó la pesa' 
id='acomodaPesas()' algoritmo='sí' expresión='0' local='i' inicio='i=0;numUnoIzq=0;numXIzq=0;numUnoDer=0;numXDer=0;numUnoPoleaIzq=0;numXPoleaIzq=0;numUnoPoleaDer=0;numXPoleaDer=0;' hacer='(PESAS[i,LADO]==L_CEN)?acomodaCentro(i):NULL;(PESAS[i,LADO]==L_IZQ)?acomodaIzquierda(i):NULL;(PESAS[i,LADO]==L_DER)?acomodaDerecha(i):NULL;(PESAS[i,LADO]==L_POL_IZQ)?acomodaPoleaIzquierda(i):NULL;(PESAS[i,LADO]==L_POL_DER)?acomodaPoleaDerecha(i):NULL;;i=i+1' mientras='i<PESAS.filas' tipo='función' info='Acomoda las pesas usando funciones auxiliares para cada posición' 
id='acomodaCentro(cual)' algoritmo='sí' expresión='0' hacer='PESAS[cual,X]=balanza.x;PESAS[cual,Y]=balanza.y -((i < PESAS.filas/2)?pesaUno.y:pesaX.y)' tipo='función' info='Acomoda las pesas al centro' 
id='acomodaIzquierda(cual)' algoritmo='sí' expresión='0' local='tipoUno' hacer='offsetUno=27*escalaImg;offsetX=39*escalaImg;platoIzq.y=balanza.y+a*sen(alfa)-plato.h;;tipoUno=(PESAS[cual,TIPO]==&squot;1&squot;);;PESAS[cual,X]=(tipoUno)?platoIzq.x +offsetUno +(numUnoIzq%2)*PESAS[cual,W]:platoIzq.x -offsetX +(numXIzq%2)*PESAS[cual,W];PESAS[cual,Y]=(tipoUno)?platoIzq.y -PESAS[cual,W]/2 -ent(numUnoIzq/2)*PESAS[cual,W]:platoIzq.y -PESAS[cual,W]/2 -ent(numXIzq/2)*PESAS[cual,W];;numUnoIzq=numUnoIzq+(tipoUno);numXIzq=numXIzq+(!tipoUno)' tipo='función' info='Acomoda las pesas a la izquierda' 
id='acomodaDerecha(cual)' algoritmo='sí' expresión='0' local='tipoUno' hacer='offsetUno=27*escalaImg;offsetX=39*escalaImg;platoDer.y=balanza.y-a*sen(alfa)-plato.h;;tipoUno=(PESAS[cual,TIPO]==&squot;1&squot;);;PESAS[cual,X]=(tipoUno)?platoDer.x +offsetUno +(numUnoDer%2)*PESAS[cual,W]:platoDer.x -offsetX +(numXDer%2)*PESAS[cual,W];PESAS[cual,Y]=(tipoUno)?platoDer.y -PESAS[cual,W]/2 -ent(numUnoDer/2)*PESAS[cual,W]:platoDer.y -PESAS[cual,W]/2 -ent(numXDer/2)*PESAS[cual,W];;numUnoDer=numUnoDer+(tipoUno);numXDer=numXDer+(!tipoUno)' tipo='función' info='Acomoda las pesas a la derecha' 
id='acomodaPoleaIzquierda(cual)' algoritmo='sí' expresión='0' local='tipoUno' hacer='offsetUno=27*escalaImg;offsetX=39*escalaImg;;pPoleaIzq.x=balanza.x-brazo.w-polea.sep*escalaImg;pPoleaIzq.y=balanza.y-platoPoleaIzq.y*escalaImg-a*sen(alfa) -7*escalaImg;;tipoUno=(PESAS[cual,TIPO]==&squot;1&squot;);;PESAS[cual,X]=(tipoUno) ? pPoleaIzq.x+offsetUno+(numUnoPoleaIzq%2)*PESAS[cual,W] : pPoleaIzq.x-offsetX+(numXPoleaIzq%2)*PESAS[cual,W];PESAS[cual,Y]=(tipoUno) ? pPoleaIzq.y-PESAS[cual,W]/2-ent(numUnoPoleaIzq/2)*PESAS[cual,W] : pPoleaIzq.y-PESAS[cual,W]/2-ent(numXPoleaIzq/2)*PESAS[cual,W];;numUnoPoleaIzq=numUnoPoleaIzq+(tipoUno);numXPoleaIzq=numXPoleaIzq+(!tipoUno)' tipo='función' info='Acomoda las pesas en el plato de la polea izquierda' 
id='acomodaPoleaDerecha(cual)' algoritmo='sí' expresión='0' local='tipoUno' hacer='offsetUno=27*escalaImg;offsetX=39*escalaImg;;pPoleaDer.x=balanza.x+brazo.w+polea.sep*escalaImg;pPoleaDer.y=balanza.y-platoPoleaDer.y*escalaImg+a*sen(alfa) -7*escalaImg;;tipoUno=(PESAS[cual,TIPO]==&squot;1&squot;);;PESAS[cual,X]=(tipoUno) ? pPoleaDer.x+offsetUno+(numUnoPoleaDer%2)*PESAS[cual,W] : pPoleaDer.x-offsetX+(numXPoleaDer%2)*PESAS[cual,W];PESAS[cual,Y]=(tipoUno) ? pPoleaDer.y-PESAS[cual,W]/2-ent(numUnoPoleaDer/2)*PESAS[cual,W] : pPoleaDer.y-PESAS[cual,W]/2-ent(numXPoleaDer/2)*PESAS[cual,W];;numUnoPoleaDer=numUnoPoleaDer+(tipoUno);numXPoleaDer=numXPoleaDer+(!tipoUno)' tipo='función' info='Acomoda las pesas a la derecha' 
id='calculaAlfa()' algoritmo='sí' expresión='0' inicio='ang=0;lim=8.5' hacer='pesoIzq=numUnoIzq +numXIzq*valX +numUnoPoleaDer +numXPoleaDer*valX;pesoDer=numUnoDer +numXDer*valX +numUnoPoleaIzq +numXPoleaIzq*valX;ang=(pesoIzq>pesoDer)?((pesoIzq!=0)?(lim-pesoDer/pesoIzq*lim):lim):ang;ang=(pesoIzq<pesoDer)?((pesoDer!=0)?(-lim+pesoIzq/pesoDer*lim):-lim):ang;;oriAlfa=grados(alfa);gradosAlfa=oriAlfa;newAlfa=ang;dirAlfa=esIgual(oriAlfa,newAlfa)?0:((oriAlfa<newAlfa)?1:-1)' tipo='función' info='Calcula el ángulo del brazo de la balanza' 
id='animaBalanza()' algoritmo='sí' expresión='0' local='cond' hacer='gradosAlfa=gradosAlfa +dirAlfa*incrAlfa;;cond=(dirAlfa>0)?(gradosAlfa>newAlfa):((dirAlfa<0)?(gradosAlfa<newAlfa):1);alfa=(cond)?radianes(newAlfa):radianes(gradosAlfa);animar=(cond)?0:animar;;acomodaPesas()' tipo='función' info='Anima la balanza' 
id='obtenerEcuacion()' algoritmo='sí' expresión='str' local='str;strIzq;strXIzq;strUnoIzq;strDer;strXDer;strUnoDer;strXPoleaIzq;strUnoPoleaIzq;strXPoleaDer;strUnoPoleaDer;operador' inicio='str=&squot;&squot;' hacer='strXIzq=(numXIzq==0)?&squot;&squot;:((numXIzq==1)?&squot;x&squot;:numXIzq+&squot;x&squot;);strUnoIzq=(numUnoIzq==0)?&squot;&squot;:numUnoIzq;strXDer=(numXDer==0)?&squot;&squot;:((numXDer==1)?&squot;x&squot;:numXDer+&squot;x&squot;);strUnoDer=(numUnoDer==0)?&squot;&squot;:numUnoDer;;strXPoleaIzq=(numXPoleaIzq==0)?&squot;&squot;:((numXPoleaIzq==1)?&squot;x&squot;:numXPoleaIzq+&squot;x&squot;);strUnoPoleaIzq=(numUnoPoleaIzq==0)?&squot;&squot;:numUnoPoleaIzq;strXPoleaDer=(numXPoleaDer==0)?&squot;&squot;:((numXPoleaDer==1)?&squot;x&squot;:numXPoleaDer+&squot;x&squot;);strUnoPoleaDer=(numUnoPoleaDer==0)?&squot;&squot;:numUnoPoleaDer;;//;strIzq_Uno=((strUnoIzq==&squot;&squot;)&&(strUnoPoleaIzq==&squot;&squot;))?&squot;&squot;:strIzq_Uno;strIzq_Uno=((strUnoIzq!=&squot;&squot;)&&(strUnoPoleaIzq==&squot;&squot;))?strUnoIzq:strIzq_Uno;strIzq_Uno=((strUnoIzq==&squot;&squot;)&&(strUnoPoleaIzq!=&squot;&squot;))?&squot; − &squot;+strUnoPoleaIzq:strIzq_Uno;strIzq_Uno=((strUnoIzq!=&squot;&squot;)&&(strUnoPoleaIzq!=&squot;&squot;))?strUnoIzq+&squot; − &squot;+strUnoPoleaIzq:strIzq_Uno;;strIzq_X=((strXIzq==&squot;&squot;)&&(strXPoleaIzq==&squot;&squot;))?&squot;&squot;:strIzq_X;strIzq_X=((strXIzq!=&squot;&squot;)&&(strXPoleaIzq==&squot;&squot;))?strXIzq:strIzq_X;strIzq_X=((strXIzq==&squot;&squot;)&&(strXPoleaIzq!=&squot;&squot;))?&squot; − &squot;+strXPoleaIzq:strIzq_X;strIzq_X=((strXIzq!=&squot;&squot;)&&(strXPoleaIzq!=&squot;&squot;))?strXIzq+&squot; − &squot;+strXPoleaIzq:strIzq_X;;strIzq=((strIzq_X==&squot;&squot;)&&(strIzq_Uno==&squot;&squot;))?&squot;0&squot;:strIzq;strIzq=((strIzq_X!=&squot;&squot;)&&(strIzq_Uno==&squot;&squot;))?strIzq_X:strIzq;strIzq=((strIzq_X==&squot;&squot;)&&(strIzq_Uno!=&squot;&squot;))?strIzq_Uno:strIzq;strIzq=((strIzq_X!=&squot;&squot;)&&(strIzq_Uno!=&squot;&squot;))?strIzq_X+((strUnoIzq!=&squot;&squot;)?&squot; + &squot;:&squot;&squot;)+strIzq_Uno:strIzq;;//;strDer_Uno=((strUnoDer==&squot;&squot;)&&(strUnoPoleaDer==&squot;&squot;))?&squot;&squot;:strDer_Uno;strDer_Uno=((strUnoDer!=&squot;&squot;)&&(strUnoPoleaDer==&squot;&squot;))?strUnoDer:strDer_Uno;strDer_Uno=((strUnoDer==&squot;&squot;)&&(strUnoPoleaDer!=&squot;&squot;))?&squot; − &squot;+strUnoPoleaDer:strDer_Uno;strDer_Uno=((strUnoDer!=&squot;&squot;)&&(strUnoPoleaDer!=&squot;&squot;))?strUnoDer+&squot; − &squot;+strUnoPoleaDer:strDer_Uno;;strDer_X=((strXDer==&squot;&squot;)&&(strXPoleaDer==&squot;&squot;))?&squot;&squot;:strDer_X;strDer_X=((strXDer!=&squot;&squot;)&&(strXPoleaDer==&squot;&squot;))?strXDer:strDer_X;strDer_X=((strXDer==&squot;&squot;)&&(strXPoleaDer!=&squot;&squot;))?&squot; − &squot;+strXPoleaDer:strDer_X;strDer_X=((strXDer!=&squot;&squot;)&&(strXPoleaDer!=&squot;&squot;))?strXDer+&squot; − &squot;+strXPoleaDer:strDer_X;;strDer=((strDer_X==&squot;&squot;)&&(strDer_Uno==&squot;&squot;))?&squot;0&squot;:strDer;strDer=((strDer_X!=&squot;&squot;)&&(strDer_Uno==&squot;&squot;))?strDer_X:strDer;strDer=((strDer_X==&squot;&squot;)&&(strDer_Uno!=&squot;&squot;))?strDer_Uno:strDer;strDer=((strDer_X!=&squot;&squot;)&&(strDer_Uno!=&squot;&squot;))?strDer_X+((strUnoDer!=&squot;&squot;)?&squot; + &squot;:&squot;&squot;)+strDer_Uno:strDer;;BALANCEADA=((numXIzq*valX +numUnoIzq -numXPoleaIzq*valX -numUnoPoleaIzq)==(numXDer*valX +numUnoDer -numXPoleaDer*valX -numUnoPoleaDer));operador=(BALANCEADA)?&squot; = &squot;:&squot; ≠ &squot;;;str=strIzq + operador + strDer' tipo='función' info='Construye una cadena que corresponde a la ecuacion representada en la balanza' 
id='coloca(cuantos,tipo,lado)' algoritmo='sí' expresión='0' local='i;cont;cond' inicio='i=0;cont=0' hacer='cond=(PESAS[i,TIPO]==tipo)&&(PESAS[i,LADO]==L_CEN)&&(cont<cuantos);PESAS[i,LADO]=(cond)?lado:PESAS[i,LADO];cont=cont +cond;;i=i+1' mientras='i<PESAS.filas' tipo='función' info='Coloca un número de objetos de cierto tipo (&squot;1&squot; o &squot;x&squot;) en algún lado de la balanza' 
id='escondeLibres(tipo)' algoritmo='sí' expresión='0' local='i' inicio='i=0' hacer='PESAS[i,VISIBLE]=((PESAS[i,TIPO]==tipo)&&(PESAS[i,LADO]==L_CEN))?0:PESAS[i,VISIBLE];i=i+1' mientras='i<PESAS.filas' tipo='función' info='Esconde las pesas libreas de un tipo' 
id='iniciar(escalaInicial)' algoritmo='sí' expresión='0' inicio='animar=0' hacer='escalaImg=escalaInicial;;//posición del centro de la balanza;balanza.x=E1._w/2;balanza.y=400;;incrAlfa=0.2;;cual=-1;lado=-1;;brazo.w=130*escalaImg;a=brazo.w;;polea.h=180;polea.sep=130;platoPoleaIzq.y=90;platoPoleaDer.y=90;;pesaUno.w=(17+3)*escalaImg;pesaX.w=(32+3)*escalaImg;pesaUno.y=150*escalaImg;pesaX.y=100*escalaImg;;plato.w=118*escalaImg;plato.h=36*escalaImg;;valX=2' tipo='función' info='Inicia la escena' 
id='reset()' algoritmo='sí' expresión='0' hacer='alfa=radianes(0) // va de 8 a -8;platoIzq.x=balanza.x-a*cos(alfa);platoDer.x=balanza.x+a*cos(alfa);platoIzq.y=balanza.y+a*sen(alfa)-plato.h;platoDer.y=balanza.y-a*sen(alfa)-plato.h;;seleccionado=-1;;initPesas()' tipo='función' info='Reinicia los valores de la escena'