Advertisement

draw a 4 leaved rose

Started by May 08, 2021 10:54 PM
2 comments, last by pbivens67 3 years, 6 months ago

I am trying to draw a 4 leaved rose using opengl and polar coordinates, I am able to draw a circle using sin and cos.

	glPushMatrix();
	glColor3f(0.0f, 1.0f, 1.0f);
	glBegin(GL_POINTS);
	float r = 10.0f;
	for (float q = 0.0f; q <= 6.28f; q += 0.01f)
	{
		float r1 = r*cos(2 * q);
		float r2 = r*sin(2 * q);
		glVertex3f(r1, r2, 0.0f);
	}
	glEnd();
	glPopMatrix();

It's hard to resist your programming exercises…

float rLeaf = r*sin(2 * q);
float r1 = rLeaf*cos(q);
float r2 = rLeaf*sin(q);

Works by putting a wave onto the circle, which gives simple precudral lobes. But more a simple flower than a rose.

Advertisement

wow that worked, thank you so much

This topic is closed to new replies.

Advertisement