New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
seems parametricCuve()bug #1586
Comments
sorry, I mean t is stop |
The code example is corrupted as shown in the comment. For example z = -1qrsin(origine_angle+pqtn)sin(B)+tR/tan(B) Could you repost with code formatting? See the github docs here: Please also include a minimal reproducible example that defines all variables used in the code. Missing variables include |
sorry, I am alos new to github.Its kind of tricky for me at least now. import cadquery as cq
from math import sin, cos, pi, tan
def parameter_n(r_1,r_2,a,B):
return(
r_1 * tan(a) / (r_2 * sin(B) )
)
#diamater of wires , helix radius and lay angle.
r_B = 0.135
R_21 = 1.100
a_21 = 0.16309787547
R_22 = 0.27
a_22 = 0.23454060987
n_22 = parameter_n(R_21,R_22,a_22,a_21)
oreigine_angle = 0
q=1
def single_helix(r,t,a):
return(
r * cos(q * t + oreigine_angle),
r * sin(q * t + oreigine_angle),
r * t/tan(a),
)
x,y,z= single_helix(R_21,0,a_21)
path= (
cq.Workplane("XY")
.parametricCurve(lambda t: single_helix(R_21,t*2*pi,a_21)
)
)
ISCW = (
cq.Workplane("XY")
.center(x,y)
.circle(r_B)
.sweep(path,isFrenet=True)
)
show_object(ISCW)
q = -1
p = -1
origine_angle = 0
def double_helix(r, R, B, n, t):
x = r * (cos(origine_angle + p * q * t * n) * cos(t) - q * sin(origine_angle + p * q * t * n) * cos(B) * sin(t)) + R * cos(t)
y = q * r * (cos(origine_angle + p * q * t * n) * sin(t) + q * sin(origine_angle + p * q * t * n) * cos(B) * cos(t)) + R * sin(t)
z = -1 * q * r * sin(origine_angle + p * q * t * n) * sin(B) + t * R / tan(B)
return x, y, z
x, y, z = double_helix(R_22, R_21, a_21, n_22, 0)
path = (
cq.Workplane("XY")
.parametricCurve(lambda t: double_helix(R_22, R_21, a_21, n_22,t*2*pi),start= 0,stop= 3/4
)
)
show_object(path) |
I get |
Sorry for my mistake, it's actually r_B. I hvae already fixed it, seeing the code above. |
Another error: |
I have fixed and test the code again, it should work now. |
It seems that you need to turn off smoothing: path1 = (
cq.Workplane("XY")
.parametricCurve(
lambda t: double_helix(R_22, R_21, a_21, n_22,t*2*pi),start= 0,stop= 1, smoothing=None
)
) The other thing is related to rendering tolerance ( |
Thank you very much! Your advice really helps me a lot. At firs I though it is some bugs. |
Hi,
i think i met with bug .I want to sweep along 3D path defined by parametricCurve(), It's Basically double helix—— wire make helix revolve a normal helix.
However,when I increase t, the curve goes wrong, and I also try to increase N, It,s dosen' work too.
And I am new to cq and code thing, I need to find way to solve this prblem.
q = -1
p = -1
origine_angle = 0
def double_helix(r, R, B, n, t):
x = r * (cos(origine_angle + p * q * t * n) * cos(t) - q * sin(origine_angle + p * q * t * n) * cos(B) * sin(t)) + R * cos(t)
y = q * r * (cos(origine_angle + p * q * t * n) * sin(t) + q * sin(origine_angle + p * q * t * n) * cos(B) * cos(t)) + R * sin(t)
z = -1qrsin(origine_angle+pqtn)sin(B)+tR/tan(B)
return x, y, z
x, y, z = double_helix(R_22, R_21, a_21, n_22, 0)
path = (
cq.Workplane("XY")
.parametricCurve(lambda t: double_helix(R_22, R_21, a_21, n_22,t2pi),start= 0,stop= 3/4
)
)
show_object(path)
when t=3/4, the curve is good, but t=1, the curve isn't the correct result.
I think that might be bug, and how to solve this.
And forgive my English,if i have ever make uncomefortabl words.
Regrads
The text was updated successfully, but these errors were encountered: