OpenGLを使用してこれを描画するメソッドを実行しています。描画は2Dです。
私は理論を知っています、あなたはウィキペディアで定義を見つけることができます、しかし私は私が間違っていることを知りません。問題は、平方根の負の解を使用して点を描くときでした。
//-----------------------------------------
// ESPIRAL DE FERMAT
//-----------------------------------------
// float a --> x-inicio
// float b --> y-inicio
// float thetaStart --> angulo de comienzo
// float thetaEnd --> angulo de fin.
// unsigned int samples --> número de muestras, por defecto 200.
//------------------------------------------------------------------
void glFermatSpiral(float a, float b, float thetaStart, float thetaEnd, unsigned int samples = 200 )
{
glBegin( GL_LINE_STRIP );
float dt = (thetaEnd - thetaStart) / (float)samples;
for( unsigned int i = 0; i <= samples; ++i )
{
// archimedean spiral
float theta = thetaStart + (i * dt);
// Specific to made a Fermat Spiral.
float r = sqrt( theta );
// polar to cartesian
float x = r * cos( theta );
float y = r * sin( theta );
// Square root means two solutions, one positive and other negative. 2 points to be drawn.
glVertex2f( x, y );
x = -r * cos( theta );
y = -r * sin( theta );
glVertex2f( x, y );
}
glEnd();
}
これが私がこのメソッドを呼び出す方法であり、描画スペースが定義されています。
glFermatSpiral(0.05, 0.2, 1.0, 25.0);
gluOrtho2D(-4, 4, -4, 4); // left, right, bottom, top
それは解決策のようです。