Representación de la ESPIRAL DE ARQUÍMEDES

"Imaginaos una línea que gira con velocidad constante alrededor de un extremo, manteniéndose siempre en un mismo plano, y un punto que se mueve a lo largo de la línea con velocidad lineal constante: ese punto describirá una espiral" ARQUÍMEDES

Esa espiral recibe el nombre de ESPIRAL DE ARQUÍMEDES.

Siendo v la velocidad constante del punto y w la velocidad angular de la línea, la ecuación de la espiral vendría dada por la fórmula r = (v/w).A (ecuación polar), donde r representa la distancia al centro de giro y A el ángulo girado.

Indice.

1.- Representación de 4 Espirales De Arquímedes.

Para representar la espiral usando JavaScript usaremos los siguientes valores: el contenedor de los ejes es 400x400 (pxs); el origen es el punto (200,200) y cada unidad es de 40 pxs. El diferencial es PI/30.

Para las espirales se toman valores de ángulo comprendidos entre 0 y 10.PI (5 giros).

Haga click en las espirales de la lista.


2.- Código utilizado.

Esta es una página que implementa las funciones dibujaEspiralArquimedes(a), dibujaPunto(m, n,txt) y ejes_cartesianos(origenX, origenY, pixelunid). El código *.css no es trivial y debería modificarse con sumo cuidado.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="PSPad editor, www.pspad.com">
<title>
18 funciones coseno
</title>
<style type="text/css">
a{ text-decoration:none;}
DIV.contenedorejes { background-color : black; width: 400; height : 400;clear : left; position : relative; left : 0px; top : 0px;}
DIV.ejeX{ width : 2px; height : 3px; clear : left; position : absolute; font-size : 0px; background-color : white; }
DIV.ejeXcompleto{ clear : left; position : absolute; font-size : 0px; background-color : white; }
DIV.ejeY{ width : 3px; height : 2px; clear : left; position : absolute; font-size : 0px; background-color : white; }
DIV.ejeYcompleto{ clear : left; position : absolute; font-size : 0px; background-color : white; }
DIV.punto{ width : 2px; height : 2px; clear : left; position : absolute; font-size : 0px; background-color : blue; }
DIV.texto{ clear : left; position : absolute; font-size : 11px; color :red; }
</style>
<script type="text/javascript">
// ancho y alto del contenedor
var ancho = 400;
var alto = 400;
var x0 = 0;
var y0 = 0;
var unid_long;
var diferencial = Math.PI/40;
if(navigator.appVersion.indexOf("MSIE") != -1) var IE = true;

function ejes_cartesianos(origenX,origenY,pixelunid){
document.getElementById('contenedorejes').innerHTML = "";
// origenes de coordenadas
x0 = origenX;
y0 = origenY;
// longitud unidades
unid_long = pixelunid;
// numero de unidades eje x+
var num_unids_x_p = (ancho-x0)/unid_long;
// numero de unidades eje x-
var num_unids_x_n = x0/unid_long;
// numero unidades eje y+
var num_unids_y_p = y0/unid_long;
// numero unidades eje y-
var num_unids_y_n = (alto-y0)/unid_long;
// EJES
// EJE X completo
x = 0;
y = y0;
punto= document.createElement("div");
if(IE) punto.setAttribute("className","ejeXcompleto");
else punto.setAttribute("class","ejeXcompleto");
punto.style.left = x + "px";
punto.style.top = y + "px";
punto.style.width = ancho + "px";
punto.style.height = 1 + "px";
document.getElementById('contenedorejes').appendChild(punto);
// eje x divisiones
// eje x +
for(i=0;i<=num_unids_x_p;i++){
x = x0 + i*unid_long;
y = y0;
punto= document.createElement("div");
if(IE) punto.setAttribute("className","ejeX");
else punto.setAttribute("class","ejeX");
punto.style.left = x + "px";
punto.style.top = y + "px";
document.getElementById('contenedorejes').appendChild(punto);
}
// eje x-
for(i=0;i<=num_unids_x_n;i++){
x = x0 - i*unid_long;
y = y0;
punto= document.createElement("div");
if(IE) punto.setAttribute("className","ejeX");
else punto.setAttribute("class","ejeX");
punto.style.left = x + "px";
punto.style.top = y + "px";
document.getElementById('contenedorejes').appendChild(punto);
}
// EJE Y
// EJE Y completo
x = x0;
y = 0;
punto= document.createElement("div");
if(IE) punto.setAttribute("className","ejeXcompleto");
else punto.setAttribute("class","ejeXcompleto");
punto.style.left = x + "px";
punto.style.top = y + "px";
punto.style.width = 1 + "px";
punto.style.height = alto + "px";
document.getElementById('contenedorejes').appendChild(punto);
// eje y divisiones
// eje y+
for(i=0;i<=num_unids_y_p;i++){
x = x0;
y = y0 - i*unid_long;
punto= document.createElement("div");
if(IE) punto.setAttribute("className","ejeY");
else punto.setAttribute("class","ejeY");
punto.style.left = x + "px";
punto.style.top = y + "px";
document.getElementById('contenedorejes').appendChild(punto);
}
// eje y-
for(i=0;i<=num_unids_y_n;i++){
x = x0;
y = y0 + i*unid_long;
punto= document.createElement("div");
if(IE) punto.setAttribute("className","ejeY");
else punto.setAttribute("class","ejeY");
punto.style.left = x + "px";
punto.style.top = y + "px";
document.getElementById('contenedorejes').appendChild(punto);
}
}
function dibujaPunto(m,n,txt){
var xP = parseFloat(m);
var yP = parseFloat(-n);
x = x0 + xP*unid_long;
y = y0 + yP*unid_long;
punto= document.createElement("div");
if(IE) punto.setAttribute("className","punto");
else punto.setAttribute("class","punto");
punto.style.left = x + "px";
punto.style.top = y + "px";
document.getElementById('contenedorejes').appendChild(punto);
if(txt!= ""){
// el texto que acompaña a los puntos
var texto = txt;
textoPunto = document.createTextNode(texto);
divTexto = document.createElement("div");
if(IE) divTexto.setAttribute("className","texto");
else divTexto.setAttribute("class","texto");
divTexto.style.left = (x+3) + "px";
divTexto.style.top = (y+6) + "px";
divTexto.appendChild(textoPunto);
document.getElementById('contenedorejes').appendChild(divTexto);
}
}
function dibujaEspiralArquimedes(a){
init();
for (i=0;i<=10*Math.PI; i += diferencial){
r = a*(i)
x = r*Math.cos(i);
y = r*Math.sin(i);
dibujaPunto(x,y,"");
}
}

function init(){
ejes_cartesianos(200,200,40);
dibujaPunto(0,0,'O');
}
</script>
</head>
<body onload="init()" style="left:10px;top:0px;">
<table width="100%">
<tr>
<td>
<p style="font-size:12px;">
<a href="javascript:dibujaEspiralArquimedes(0.1)">Espiral <b><i>v/w</i></b> = 0,1</a>
<a href="javascript:dibujaEspiralArquimedes(0.12)">Espiral <b><i>v/w</i></b> = 0,12</a>
<a href="javascript:dibujaEspiralArquimedes(0.13)">Espiral <b><i>v/w</i></b> = 0,13</a>
<a href="javascript:dibujaEspiralArquimedes(0.15)">Espiral <b><i>v/w</i></b> = 0,15</a>
</p>
</td>
<td>
<div id="contenedorejes" class="contenedorejes">
</div>
</td>
</tr>
</table>
</body>
</html>



Añadir a Favoritos Internet Explorer

Menú

Categorías


Lo Último

  Mis programas  Matemáticas  Geometría  Programación WEB  Flash MX  Variados
Dedicado a ANGELES y a RAMON.
Realizado por José Antonio López Lorenzo (JALL)
Vigo - Galicia - España -Europa