Dibujar puntos equidistantes en una espiral.
Necesito un algoritmo para calcular la distribución de puntos en una trayectoria en espiral.
Los parámetros de entrada de este algoritmo deben ser:
Ancho del bucle (distancia desde el bucle más interno)Distancia fija entre los puntos.El número de puntos a dibujar.La espiral para dibujar es unaespiral arquimediana y los puntos obtenidos deben serequidistante de cada uno.
El algoritmo debe imprimir la secuencia de las coordenadas cartesianas de puntos individuales, por ejemplo:
Punto 1: (0.0) Punto 2: (..., ...) ........ Punto N (..., ...)
¡El lenguaje de programación no es importante y toda la ayuda es muy apreciada!
EDITAR:
Ya tengo y modifico este ejemplo de este sitio:
//
//
// centerX-- X origin of the spiral.
// centerY-- Y origin of the spiral.
// radius--- Distance from origin to outer arm.
// sides---- Number of points or sides along the spiral's arm.
// coils---- Number of coils or full rotations. (Positive numbers spin clockwise, negative numbers spin counter-clockwise)
// rotation- Overall rotation of the spiral. ('0'=no rotation, '1'=360 degrees, '180/360'=180 degrees)
//
void SetBlockDisposition(float centerX, float centerY, float radius, float sides, float coils, float rotation)
{
//
// How far to step away from center for each side.
var awayStep = radius/sides;
//
// How far to rotate around center for each side.
var aroundStep = coils/sides;// 0 to 1 based.
//
// Convert aroundStep to radians.
var aroundRadians = aroundStep * 2 * Mathf.PI;
//
// Convert rotation to radians.
rotation *= 2 * Mathf.PI;
//
// For every side, step around and away from center.
for(var i=1; i<=sides; i++){
//
// How far away from center
var away = i * awayStep;
//
// How far around the center.
var around = i * aroundRadians + rotation;
//
// Convert 'around' and 'away' to X and Y.
var x = centerX + Mathf.Cos(around) * away;
var y = centerY + Mathf.Sin(around) * away;
//
// Now that you know it, do it.
DoSome(x,y);
}
}
Pero la disposición del punto es incorrecta, los puntos no son equidistantes entre sí.
El ejemplo de distribución correcta es la imagen de la izquierda: