ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 10 Apr 2022 23:53:00 +0200How to flip normals of Graphics3d faces?https://ask.sagemath.org/question/61908/how-to-flip-normals-of-graphics3d-faces/Is there an easy way to flip the normals for all the faces of a `sage.plot.plot3d.base.Graphics3d` or `sage.plot.plot3d.base.Graphics3dGroup` object?
I checked the source of https://github.com/sagemath/sage/blob/develop/src/sage/plot/plot3d/base.pyx but couldn't find any answers there.
### Background:
I am generating a 3-dimensional surface on the YZ plane via `sage.plot.plot.parametric_plot` using long-running functions and want to mirror this surface by the XY plane to produce a final mesh which includes both the original and mirrored surfaces.
mySurface = parametric_plot(
[
0,
lambda u, v: longRunningYFunction(u, v),
lambda u, v: longRunningZFunction(u, v)
],
...
)
The reason I want to mirror the original surface instead of regenerating it is because the long-running functions take a very long time to complete, so doing it this way effectively cuts down the processing time in half.
I tried a few ways to mirror the surface:
- Rotating by `180°` around the Y axis
mirroredSurface = mySurface.rotateY(pi)
- Scaling by `-1` in the Z direction:
mirroredSurface = mySurface.scale([1, 1, -1])
and when I display or write both surfaces it looks ok:
show(mySurface + mirroredSurface)
but when inspected more closely, the normals of `mirroredSurface` are in the opposite direction of `mySurface`. This requires me to manually flip the surfaces with Blender.
### Question:
Is there any extension or function I can apply on the `Graphics3d` object `mirroredSurface` that would flip all the surface normals?
Something like the following?
mirroredSurface.flip_normals()
# or
flip_normals(mirroredSurface)
Dan-KSun, 10 Apr 2022 23:53:00 +0200https://ask.sagemath.org/question/61908/