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

offset() function does not keep face normal #564

Closed
Windfisch opened this issue Feb 21, 2024 · 2 comments
Closed

offset() function does not keep face normal #564

Windfisch opened this issue Feb 21, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Windfisch
Copy link

Calling offset(some_face, amount = -3) does not keep the face normal. Apparently, it always rotates the face normal to point towards +X, +Y or +Z direction.

This is a problem if you depend on the normal of a face, e.g. for subsequent extrude operations.

Reproducer

from build123d import *
from ocp_vscode import *

box = Box(10,10,10)

offsets = [offset(face, amount=-3) for face in box.faces()]

show(offsets)

Expected behavior

offsetbug-expected

(faces that are facing towards the camera are rendered in pink, faces that are facing away from the camera are gray)

Actual behavior

offsetbug

@gumyr
Copy link
Owner

gumyr commented Feb 21, 2024

offset is working with Wires and I guess in some circumstances the direction of the perimeter after an offset is reversed resulting in the Face normal being flipped (the winding order of the outer wire determines the normal). It shouldn't be too difficult to check for the reversal and if so, use reverse to flip the direction of the Wire before building the new Face.

@gumyr gumyr added the bug Something isn't working label Feb 22, 2024
@gumyr gumyr added this to the Gating Release 1.0.0 milestone Feb 22, 2024
@gumyr
Copy link
Owner

gumyr commented Feb 22, 2024

Fixed:

box = Box(10, 10, 10)
original_faces = box.faces()
offset_faces = [offset(face, amount=-3).face() for face in original_faces]

for original_face, offset_face in zip(original_faces, offset_faces):
    assert original_face.normal_at() == offset_face.normal_at()

passes
image

@gumyr gumyr closed this as completed Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants