CadQuery / CadQuery/cadquery

Sweep Path Orientation Issue with Parametric Wave Path

Open
#1,723 8 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
5.8k
Forks
541
Avg merge
3d 2h
Merged PRs (30d)
5

Description

When sweeping a rectangular profile along a parametric wave path, the profile's orientation changes incorrectly as the sweep progresses. This happens regardless of whether `isFrenet` is set to `True` or `False`. The sweep initially aligns with the path correctly but distorts as it continues, making the result inconsistent.

**Code Example**
Below is a minimal, complete example to reproduce the issue. This can be copied and run directly in CQ-Editor:

`import cadquery as cq
import math

# Parameters for the wave spring
t1 = 0 # Start parameter
t2 = 50 # End parameter
num_points = 500 # Number of points for smoothness
radius = 50
(width, thickness) = (4, 2)

# Generate the wave spring path
points = []
delta_t = (t2 - t1) / num_points
for i in range(num_points + 1):
t = t1 + i * delta_t
# Parametric equations for the wave spring
x = radius * math.sin(t)
y = radius * math.cos(t)
z = 7 * math.sin(3.5 * t) + 3 * t
points.append((x, y, z))

# Create the wave path as a spline
wave_path = cq.Workplane("XY").spline(points)

# Define a rectangular profile and sweep along the path
result = (
cq.Workplane("YZ") # Profile aligned to XZ plane
.center(radius, 0) # Offset to the radius of the wave spring
.rect(width, thickness) # Create a rectangle profile
.sweep(wave_path, isFrenet=False) # Sweep along the wave path
)`

**Observed Behavior**
The sweep starts with the profile aligned correctly to the path.
As the path progresses, the profile's orientation distorts and deviates from the intended alignment.

**Expected Behavior**
The rectangular profile should maintain consistent orientation along the entire wave path, ensuring a uniform sweep.

**Screenshots**
Sweep with normal=(0,0,1):
![with normal assigned](https://github.com/user-attachments/assets/a29352c6-303e-4bab-98f1-43232962da5f)

Sweep with no normal:
![with no normal](https://github.com/user-attachments/assets/cda91775-6e30-44f7-98d0-874a4e080a7b)

Sweep with a circular profile (for comparison)(best to understand how it changes with the path as the path(black line) goes from outward to inward)
![circular sweep](https://github.com/user-attachments/assets/31403adc-fb36-4f4b-a748-6ffa588a4546)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.