Scaling of Shapes
Scorri per mostrare il menu
Scaling is a fundamental geometric transformation that changes the size of a shape while preserving its overall structure. When you apply scaling to a geometric figure, each point of the shape moves closer to or further from a fixed point, usually the origin, by a specific factor. This process can be uniform, where all dimensions are scaled by the same factor, or non-uniform, where different dimensions are scaled by different factors.
In uniform scaling, every coordinate of each point is multiplied by the same value. This keeps the proportions of the shape the same, so a square remains a square, and a circle remains a circle—just larger or smaller. In non-uniform scaling, each coordinate axis can have a different scaling factor. For instance, you might stretch a rectangle horizontally while keeping its height the same, turning it into a wider rectangle.
Scaling transformations are commonly used in computer graphics, modeling, and design to resize objects or adjust their proportions. When you scale a shape, its area and perimeter change in predictable ways: for uniform scaling by a factor of k, the perimeter is multiplied by k, and the area by k^2. However, non-uniform scaling can distort the shape, changing angles and relative side lengths.
12345678910111213141516171819202122232425262728import numpy as np import matplotlib.pyplot as plt def scale_polygon(vertices, scale_x, scale_y): scale_matrix = np.array([[scale_x, 0], [0, scale_y]]) return vertices @ scale_matrix.T # Define a triangle triangle = np.array([[1, 1], [3, 1], [2, 3], [1, 1]]) # Uniform scaling by factor 2 scaled_uniform = scale_polygon(triangle, 2, 2) # Non-uniform scaling: x by 2, y by 0.5 scaled_nonuniform = scale_polygon(triangle, 2, 0.5) # Plot original and scaled triangles plt.figure(figsize=(6, 6)) plt.plot(triangle[:,0], triangle[:,1], 'o-', label='Original') plt.plot(scaled_uniform[:,0], scaled_uniform[:,1], 'o-', label='Uniform scale (2x)') plt.plot(scaled_nonuniform[:,0], scaled_nonuniform[:,1], 'o-', label='Non-uniform scale (2x, 0.5y)') plt.legend() plt.axis('equal') plt.title('Scaling Transformations of a Triangle') plt.xlabel('X') plt.ylabel('Y') plt.show()
Grazie per i tuoi commenti!
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione