Skip to content

Incorrect tangent ending of spline #1869

@josyb

Description

@josyb

I am trying to create a train switch - using the following code for a single rail (simplified to a round bar).

def splinetrack(x, y):
    pts = [(0, 0), (x / 2, y / 2), (x, y)]
    tgts = [(x, 0), None, (2 * x, y)] # 1
    # tgts = [(x, 0), (x / 2, y / 2 + x * 10), (2 * x, y)] # 2
    # tgts = [(x, 0), None, (2 * x, 0)] # 3
    path = cq.Workplane("XY").spline(pts, tgts)
    return cq.Workplane("YZ").circle(3.0).sweep(path)

generates this:

Image

If I (try to) force a 90 degrees tangent in the middle you see the effect even better:

Image

Experimenting I stumbled on the third 'tgts' definition which produces the correct 90 degrees angle.
Can someone explain?

Oops! I found it myself: the tangent vectors in the spline function are specified as starting from (0,0) - It would be good if the CadQuery 2 Documentation mentioned that :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions