Skip to content

Commit

Permalink
Initial approach to the model
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeicor committed Dec 2, 2023
1 parent 8d92fe3 commit 384802b
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,45 @@
eps = 1e-5 * MM # A small number

# ...
protection_thickness = 2 * wall
samples_pitch = 10 # Number of pitch angles (up-down front) to sample
samples_yaw = 10 # Number of yaw angles (left-right front) to sample


# ================== MODELLING ==================

# Load the boot model, which must be aligned with the base at the origin, centered in X and Y and with forward direction in X+
# Slow import...
boot = Mesher().read("boot.stl" if getenv(
"final_boot") else "boot-simplified.stl")[0]

boot_half_x = boot.bounding_box().size.X / 2
boot_half_y = boot.bounding_box().size.Y / 2

# %%

all_lines = []
for yaw_sample in map(lambda x: x / (samples_yaw-1), range(samples_yaw)):
with BuildLine(Plane.XY.rotated((0, -90 * yaw_sample, 0))) as line_tmp:
CenterArc((0, 0, 0), boot_half_x + 1, -70, 140)
all_lines.append(line_tmp)

all_collisions = []
for pitch_sample in map(lambda x: x / (samples_pitch-1), range(samples_pitch)):
all_collisions_line = []
for line in all_lines:
# Throw a ray to the center of the boot
ray_from = line._obj@pitch_sample
ray_to = Vector(0, 0, 0)
loc = boot.find_intersection(
Axis(ray_from, ray_to - ray_from))[0][0] # Position of first
# print("Ray from %s to %s: %s" % (ray_from, ray_to, res))
all_collisions_line.append(loc)
all_collisions.append(all_collisions_line)

with BuildPart() as obj:
Box(20*CM, 20*CM, 20*CM)
add(boot, mode=Mode.SUBTRACT)
add(Face.make_surface_from_array_of_points(
all_collisions).thicken(protection_thickness))

if "ocp_vscode" in locals():
ocp_vscode.reset_show()
Expand Down

0 comments on commit 384802b

Please sign in to comment.