2

I'm trying to create the thinnest possible cube in Blender using python, like this.

mesh.from_pydata(pts, [], [(0, 1, 2, 3)])

print(mesh)

Get geometry to extrude

bm = bmesh.new() bm.from_mesh(mesh) bm.faces.ensure_lookup_table() faces = [ bm.faces[0] ]

Extrude

extruded = bmesh.ops.extrude_face_region(bm, geom=faces)
translate_verts = [v for v in extruded['geom'] if isinstance(v, BMVert)]

----------------------------------------------------------

up = Vector((1 / (10 ** 16), 0, 0))

----------------------------------------------------------

bmesh.ops.translate(bm, vec=up, verts=translate_verts) bmesh.ops.delete(bm, geom=faces, context="FACES") bm.to_mesh(mesh) mesh.update()

However, for high enough exponents, the geometry will not get extruded.

How small can the extrusion by for it to work?

simone
  • 745
  • 4
  • 14
  • I think if we're talking floating point precision, functionally two points are considered on the same exact spot if their absolute difference is < 10^-8 units. Might be wrong though, didn't test it. Maybe your problem can be solved in another way, what's your end goal here ? – Gorgious Nov 12 '21 at 10:11
  • @Gorgious - I'm trying to create cross-sections as explained here https://blender.stackexchange.com/questions/58153/create-cross-sections-and-2d-planes-in-blender - but in Python. So that would be the extrude size that I'd use. I can work around it, but I was also curious about that per se – simone Nov 12 '21 at 11:23

1 Answers1

1

Welcome to the wacky world of IEEE 754, floating point implementation in CPUs and GPUs, Python floating Point, C floating point, and Blender's internal use of floating point.

If ever there was an answer where "it depends" applies it's the answer to this question; but I'm going to take a shortcut, skip a lot of uncommon corner cases, and simplify.

Blender uses what IEEE 754 calls single precision floating point internally. This is also commonly 32 bit precision. The smallest number that can be represented in a 32 bit IEEE floating point is $10^{-126}$ but more importantly, the smallest difference between two floating point numbers is $10^{-20}$

However, the farther those two numbers get from 0, the larger the difference, and Blender uses distance, involving squaring numbers, to determine things like merge by distance.

So, in the final analysis, depending on the computer you're using and the version of Blender, the smallest distance possible is somewhere between $10^{-8}$ and $10^{-10}$ if your numbers are close to 0.

Marty Fouts
  • 33,070
  • 10
  • 35
  • 79