Rhodonea Curve
The Rhodonea Curve (also known as the rose in mathematics) is a curve with the formula
r = cos(n*theta), where n is an integer indicating the number of petals.
The formula mentioned above is in polar form. However, because pixel positions in computer graphics are expressed in cartesian rather than polar form, the curve must be redescribed as a collection of all points (x, y) in parametric equations.
def drawRhodoneaCurve():
positions = []
for i in range(0, 361):
# formula of rhodonea curve
r = size * sin(radians(n * i))
# Converting to cartesian coordinates
x = r * cos(radians(i))
y = r * sin(radians(i))
list.append(positions, (width / 2 + x, height / 2 + y))
# Draws a set of line segments connected by set of vertices positions
pygame.draw.lines(window, (0, 0, 0), False, positions, 3)
You can also try this code with Online Python Compiler
Run Code
After updating the definition of drawRhodoneaCurve() in our original code and then calling it just above the “pygame.display.flip()” line. We’ll get output like the image below:
Rhodonea curve (n = 5)
Explanation

We calculate the vertices using the formula.

We save a list named points that contains all of the rose's vertices, and then we feed this list of vertices to pygame.draw.lines, which generates a series of continuous straight lines, which we use to draw a polygonal chain.

By default, PyGame has its coordinates in the TopLeft corner. So in order to draw our pattern in the center of the screen we are shifting the coordinates by (width/2, height/2).
Maurer Rose
A Maurer rose of the rose r = sin(nθ) is made up of 360 lines connecting the 361 points above. A Maurer rose is a roseshaped polygonal curve with vertices.
Evolution of a Maurer rose, where n = 2 and d = 29 (Source: Wikipedia)
Update the definition of drawMaurerRose(d) function in our original code and then call it. While calling make sure to provide the value of d.
def drawMaurerRose(d):
positions =[]
for i in range(0, 361):
# The equation of a maurer rose
k = i * d
r = size * sin(radians(n * k))
# Converting to cartesian coordinates
x = r * cos(radians(k))
y = r * sin(radians(k))
list.append(positions, (width / 2 + x, height / 2 + y))
# Draws a set of line segments connected by set of vertices points
pygame.draw.lines(window, (0, 0, 0), False, positions, 2)
You can also try this code with Online Python Compiler
Run Code
After running, implement the above code in our original program and then run it. We’ll get output like this:
Maurer Rose (n=5 and d=29)
Explanation

The name of the function has been changed from drawRhodoneaCurve to drawMaurerRose, and it now takes an extra parameter d!

We now have a new variable k, which is derived from the formula. Its value is equal to i*d at each iteration.
 We now use k instead of i.
Frequently Asked Questions
What is Python pygame used for?
The pygame library is an opensource module for the Python programming language that is designed to aid in the development of games and other multimedia applications. Pygame, which is based on the SDL (Simple DirectMedia Layer) development library, can run on a variety of platforms and operating systems.
Who introduced the concept of Maurer rose?
The concept of a Maurer rose was introduced by Peter M. Maurer. A Maurer rose consists of some lines that connect some points on a rose curve.
What does rose mean in math?
In mathematics, a rose or rhodonea curve is a sinusoid with no phase angle that is displayed in polar coordinates and described by either the cosine or sine functions. Rose curves, or "rhodonea," were named by Guido Grandi, an Italian mathematician who researched them between 1723 and 1728.
Why is it called a rose curve?
Rose curves are named after the loops they form, which resemble petals. The number of petals will be determined by the value of n.
Conclusion
In this article, we have extensively discussed Rhodonea Curves and Maurer Rose in Python.
We hope that this blog has helped you enhance your knowledge about Rhodonea Curves and Maurer Rose and if you would like to learn more, check out our articles on our Website.
Refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and Algorithms, Competitive Programming, JavaScript, System Design, and many more! If you want to test your competency in coding, you may check out the mock test series and participate in the contests hosted on Coding Ninjas Studio! But if you have just started your learning process and are looking for questions asked by tech giants like Amazon, Microsoft, Uber, etc; you must look at the problems, interview experiences, and interview bundle for placement preparations.
Nevertheless, you may consider our paid courses to give your career an edge over others!
Do upvote our blogs if you find them helpful and engaging!
Happy Learning!