Skip to content
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

Add convenience methods to correct for non-Z-axis entity normals. #160

Open
brettfo opened this issue Apr 19, 2021 · 1 comment
Open

Add convenience methods to correct for non-Z-axis entity normals. #160

brettfo opened this issue Apr 19, 2021 · 1 comment

Comments

@brettfo
Copy link
Member

brettfo commented Apr 19, 2021

E.g., Commonly AutoCAD will save a CIRCLE or ARC with a negative Z-axis normal vector which negates the X coordinate of the center and can also cause problems with the start/end angles.

There should be some sort of method (exact shape TBD) that does the following:

public static DxfEntity CorrectForExtrusionVector(this DxfEntity entity)
{
    if (entity.Normal != DxfVector.ZAxis)
    {
        switch (entity.EntityType)
        {
            case DxfEntityType.Circle:
                // TODO: make the necessary transformations to correct for normal and return a copy
            ...
        }
    }

    return entity; // no change
}

Alternately, the individual values could be handled:

public static DxfPoint CorrectForExtrusionVector(this DxfEntity entity, DxfPoint point)
{
    if (entity.Normal != DxfVector.ZAxis)
    {
        // TODO: transform the point as appropriate
    }

    return point; // no change
}
@uzername
Copy link

uzername commented Apr 5, 2024

I encounter that sometimes too. Especially it was noticeable for arcs. Transformation steps for me are:

  1. negate X coordinate of arc center ( ArcCenterX = -ArcCenterX )
  2. Horizontally mirror start angle and end angle
  3. Swap values between start angle and end angle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants