Representación de la ESPIRAL LOGARITMICA

Fue descrita, por primera vez, por René Descartes, quien un año después de la publicación de La Géométrie, se va encontrar con la curva mecánica que responde al problema planteado por Galileo sobre la trayectoria de la caída de un cuerpo atraído por la tierra en rotación.

Siendo La ecuación de la espiral vendrá dada por la fórmula r = C.ek.A (ecuación polar), donde r representa la distancia al centro de giro y A el ángulo girado; y C y k son constantes.

Indice.

1.- Representación de 8 Espirales Logarítmicas.

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 segun los distintos valores de C y k


2.- Código utilizado.

Esta es una página que implementa las funciones dibujaEspiralLogaritmica(C,k), 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>
ESPIRAL LOGARITMICA
</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 : RED; } DIV.ejeXcompleto{ clear : left; position : absolute; font-size : 0px; background-color : RED; } DIV.ejeY{ width : 3px; height : 2px; clear : left; position : absolute; font-size : 0px; background-color : RED; } DIV.ejeYcompleto{ clear : left; position : absolute; font-size : 0px; background-color : RED; } DIV.punto{ width : 2px; height : 2px; clear : left; position : absolute; font-size : 0px; background-color : yellow; } 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/30;
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 dibujaEspiralLogaritmica(C,k){
init();
for (i=0;i<=10*Math.PI; i += diferencial){
r = C*Math.exp(k*i);
x = r*Math.cos(i);
y = r*Math.sin(i);
if (x <= 4 && x >= -4 && y <= 4 && y >= -4) 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:dibujaEspiralLogaritmica(0.1,0.1)">Espiral
<b><i>C</i></b> = 0,1; <b><i>k</i></b> = 0,1</a><br>
<a href="javascript:dibujaEspiralLogaritmica(0.12,0.1)">Espiral
<b><i>C</i></b> = 0,12; <b><i>k</i></b> = 0,1</a><br>
<a href="javascript:dibujaEspiralLogaritmica(0.14,0.1)">Espiral
<b><i>C</i></b> = 0,14; <b><i>k</i></b> = 0,1</a><br>
<a href="javascript:dibujaEspiralLogaritmica(0.16,0.1)">Espiral
<b><i>C</i></b> = 0,16; <b><i>k</i></b> = 0,1</a><br>
<a href="javascript:dibujaEspiralLogaritmica(0.07,0.1)">Espiral
<b><i>C</i></b> = 0,07; <b><i>k</i></b> = 0,1</a><br>
<a href="javascript:dibujaEspiralLogaritmica(0.07,0.11)">Espiral
<b><i>C</i></b> = 0,07; <b><i>k</i></b> = 0,11</a><br>
<a href="javascript:dibujaEspiralLogaritmica(0.07,0.12)">Espiral
<b><i>C</i></b> = 0,07; <b><i>k</i></b> = 0,12</a><br>
<a href="javascript:dibujaEspiralLogaritmica(0.07,0.13)">Espiral
<b><i>C</i></b> = 0,7; <b><i>k</i></b> = 0,13</a><br>
</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