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

extrusion of sketches goes in the wrong direction #89

Closed
tve opened this issue Jul 23, 2023 · 2 comments
Closed

extrusion of sketches goes in the wrong direction #89

tve opened this issue Jul 23, 2023 · 2 comments

Comments

@tve
Copy link

tve commented Jul 23, 2023

In the following example I'm extruding a sketch along the Y axis but a positive extrusion value results in extruding towards -Y. A subsequent translateY of the object has the direction of the Y axis correct. Example:

export default function main(p) {
  const tri1 = replicad.draw().vLine(10).lineTo([10,0]).close().sketchOnPlane("XZ").extrude(10)
  const tri2 = replicad.draw().vLine(10).lineTo([10,0]).close().sketchOnPlane("XZ").extrude(5)
  return [
    { shape: tri1, name: "tri1", color: "blue" },
    { shape: tri2.translateY(20), name: "tri1", color: "blue" },
  ]
}

image

@sgenoud
Copy link
Owner

sgenoud commented Jul 30, 2023

This is due to the (mathematical definition of the XZ plane). If you do the cross product of X (1, 0, 0) and Z (0, 0, 1) you obtain -Y (0, -1, 0). When sketching in a plane, you will, by default extrude in the direction of the normal of the plane, -Y in this case.

That said, I completely understand the confusion, and I am not sure if that is the best choice (i.e. to be mathematically consistent instead of intuitive). There might be some edge case that pop when we start ignoring mathematical consistency.

The ZX plane is the one you where expected to get...

@tve
Copy link
Author

tve commented Jul 31, 2023

Ah, right hand rule... I forgot... I'll get used to using ZX instead of XZ.
I fear that if you make it "intuitive" via some special rule things will either be wrong or really confusing when someone uses a pivoted plane... E.g. what if I take XZ and pivot it 120 degrees around the Z axis, now what's + vs. -?

@tve tve closed this as completed Jul 31, 2023
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