Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Visualizing Approximations | Approximating Complex Figures
Geometric Modelling with Python

Visualizing Approximations

Swipe to show menu

To understand how well a polygonal approximation matches a complex curve, it is helpful to visualize both the original curve and its approximation on the same plot. This approach allows you to observe where the approximation closely follows the curve and where it deviates. You can use matplotlib to display both shapes together, assigning different colors or line styles for clarity. Typically, you will:

  • Generate points for the original curve using its mathematical equation;
  • Compute the vertices of the polygonal approximation;
  • Plot both sets of points or lines on the same axes for direct comparison.

This process is especially useful for circles, ellipses, or any smooth curve where visual differences are important for evaluating the quality of the approximation.

12345678910111213141516171819202122232425
import numpy as np import matplotlib.pyplot as plt # Parameters for the circle center = (0, 0) radius = 1 # Generate points for the original circle theta = np.linspace(0, 2 * np.pi, 500) x_circle = center[0] + radius * np.cos(theta) y_circle = center[1] + radius * np.sin(theta) # Generate points for the polygonal approximation (e.g., hexagon) num_sides = 6 theta_poly = np.linspace(0, 2 * np.pi, num_sides + 1) x_poly = center[0] + radius * np.cos(theta_poly) y_poly = center[1] + radius * np.sin(theta_poly) plt.figure(figsize=(6,6)) plt.plot(x_circle, y_circle, label="Original Circle", color="blue") plt.plot(x_poly, y_poly, label="Polygonal Approximation", color="red", linestyle="--", marker="o") plt.gca().set_aspect("equal") plt.legend() plt.title("Comparison of Circle and Polygonal Approximation") plt.show()
question mark

Which of the following best describes the purpose of plotting both the original curve and its polygonal approximation on the same axes?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 6

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Section 3. Chapter 6
some-alt