Elements icon indicating copy to clipboard operation
Elements copied to clipboard

Solid.SweepFaceAlongCurve not respecting Transform zAxis twist

Open sanchez opened this issue 2 years ago • 3 comments

I have implemented a custom ICurve with the following logic to generate the frames:

public Transform[] Frames(double startSetback = 0, double endSetback = 0)
{
    Transform[] transforms = _line.Frames(startSetback, endSetback);
    Transform[] newTransforms = new Transform[transforms.Length];

    for (int i = 0; i < transforms.Length; i++)
    {
        Transform transform = transforms[i];
        Plane plane = new Plane(transform.Origin, transform.ZAxis);

        Vector3 realUp = plane.ClosestPoint(Vector3.ZAxis + transform.Origin) - transform.Origin;
        Transform newTransform = new Transform(transform.Origin, realUp, transform.ZAxis);

        newTransforms[i] = newTransform;
    }

    return newTransforms;
}

I have noticed in the viewer though that when I pass this curve into the Solid.SweepFaceAlongCurve it is not respecting the original transforms rotation around the zAxis of the transform:

image

Here the purple geometry is the result of the sweep, with arrows being Transform.ToModelCurves() and an additional arrow on the realUp to verify the xAxis is correctly set in the transform. The problem is on the upper half of the geometry the Solid result has twisted but the transforms have not.

Expected behavior For the solid operation to respect the xAxis configuration of the Transform on the curve

sanchez avatar Aug 12 '22 00:08 sanchez

I think it's because here you are getting the XY plane of the transform, which could have a twist in the plane? https://github.com/hypar-io/Elements/blob/master/Elements/src/Geometry/Solids/Solid.cs#L714

sanchez avatar Aug 12 '22 00:08 sanchez

Relates to #968 #819

ikeough avatar Apr 17 '23 18:04 ikeough

I don't think this relates to #819, I believe this is a bug to do with a Transform being converted to a Plane and then back to a Transform, therefore the rotation of the Transform around it's local ZAxis is lost and recalculated (resulting in different X and Y axis). I can see how #968 and #819 relate to each other but I don't see how this issue relates to them?

sanchez avatar Apr 17 '23 23:04 sanchez