Skip to content

Instantly share code, notes, and snippets.

@davecampbell
Created March 5, 2025 18:24
Show Gist options
  • Save davecampbell/b501d546129858e61e22de39a2a32e51 to your computer and use it in GitHub Desktop.
Save davecampbell/b501d546129858e61e22de39a2a32e51 to your computer and use it in GitHub Desktop.
squares on wafers
import math
def squares_with_coordinates(d, b, w):
"""
Compute the coordinates of the center of each square inside a circular wafer.
Parameters:
d (float): Wafer diameter in mm
b (float): Border width in mm
w (float): Square size in mm
Returns:
list of tuples: Each tuple represents (x, y) coordinates of a square center.
"""
# Compute the effective radius after removing the border
effective_radius = (d - 2 * b) / 2
# Find the number of full squares that fit along the diameter
max_rows = math.floor(effective_radius / w)
square_centers = []
# Iterate through each row from top to bottom
for i in range(-max_rows, max_rows + 1):
y_center = i * w # Compute y-coordinate of row center
row_width = math.floor(math.sqrt(effective_radius**2 - (y_center) ** 2) / w)
for j in range(-row_width, row_width + 1):
x_center = j * w # Compute x-coordinate of column center
square_centers.append((x_center, y_center))
return square_centers
# Example usage
wafer_diameter = 4 * 25.4 # Convert inches to mm
border = 2 # in mm
square_width = 3 # in mm
# Compute and store square center coordinates
square_coordinates = squares_with_coordinates(wafer_diameter, border, square_width)
# Print results
print(f"Total squares: {len(square_coordinates)}")
print("Sample coordinates:", square_coordinates[:10]) # Print first 10 coordinates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment