Skip to content

Incorrect tangent ending of spline #1870

Answered by lorenzncode
josyb asked this question in Q&A
Discussion options

You must be logged in to vote

I have another question though: how can I find the actual angle of the tangent in the middle of the generated spline; I am sure it will be calculated somewhere in the code?

import cadquery as cq
from math import degrees

x = 170
y = 50

pts = [(0, 0), (x / 2, y / 2), (x, y)]

tgts = [(1, 0), (1, 1)]  # ~15 deg at midpoint
# tgts = [(1, 0), None, (1, 1)]  # ~15 deg same as above
# tgts = [(1, 0), (1, 0)]  # ~27 deg
# tgts = [(1, 0), (1, 1), (1, 0)]  # 45 deg
# tgts = [(1, 0), (0, 1), (1, 0)]  # 90 deg

path = cq.Workplane("XY").spline(pts, tgts)

# tangetAt(0.5) is default
tangent_mid = path.val().tangentAt()
anglex = degrees(tangent_mid.getAngle(cq.Vector(1, 0, 0)))
print(tangent_mid)
p…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by adam-urbanczyk
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #1869 on July 15, 2025 10:16.