Skip to main content
Became Hot Network Question
Tweeted twitter.com/StackMma/status/1362507203756908547
Added escape character to the * in the block quote to prevent italic formatting
Source Link
MarcoB
  • 67.7k
  • 18
  • 96
  • 198

Suppose we have a MeshRegion that we want to export to an obj file with, say double precision. Is that possible with Export? And how would we do that? The documentation on "OBJ" does not list any options. I am asking explicitly about Export. Of course, I could write my own OBJ exporter, but this would be somewhat awkward. (I've actually done it already.)

The default seems to export only about 6 decimal digits as the following example is supposed to show:

R = MeshRegion[
   {{0., 0., 0.}, {Sqrt[2.], 0., 0.}, {0., Sqrt[2.], 0.}},
   Triangle[{{1, 2, 3}}]
   ];
file = FileNameJoin[{$TemporaryDirectory, "a.obj"}];
Export[file, R];
MeshCoordinates[Import[file]] - MeshCoordinates[R]

{{0., 0., 0.}, {-3.6004810^-6, 0., 0.}, {0., -3.6004810^60048*10^-6, 0., 0.}, {0., -3.60048*10^-6, 0.}}

Suppose we have a MeshRegion that we want to export to an obj file with, say double precision. Is that possible with Export? And how would we do that? The documentation on "OBJ" does not list any options. I am asking explicitly about Export. Of course, I could write my own OBJ exporter, but this would be somewhat awkward. (I've actually done it already.)

The default seems to export only about 6 decimal digits as the following example is supposed to show:

R = MeshRegion[
   {{0., 0., 0.}, {Sqrt[2.], 0., 0.}, {0., Sqrt[2.], 0.}},
   Triangle[{{1, 2, 3}}]
   ];
file = FileNameJoin[{$TemporaryDirectory, "a.obj"}];
Export[file, R];
MeshCoordinates[Import[file]] - MeshCoordinates[R]

{{0., 0., 0.}, {-3.6004810^-6, 0., 0.}, {0., -3.6004810^-6, 0.}}

Suppose we have a MeshRegion that we want to export to an obj file with, say double precision. Is that possible with Export? And how would we do that? The documentation on "OBJ" does not list any options. I am asking explicitly about Export. Of course, I could write my own OBJ exporter, but this would be somewhat awkward. (I've actually done it already.)

The default seems to export only about 6 decimal digits as the following example is supposed to show:

R = MeshRegion[
   {{0., 0., 0.}, {Sqrt[2.], 0., 0.}, {0., Sqrt[2.], 0.}},
   Triangle[{{1, 2, 3}}]
   ];
file = FileNameJoin[{$TemporaryDirectory, "a.obj"}];
Export[file, R];
MeshCoordinates[Import[file]] - MeshCoordinates[R]

{{0., 0., 0.}, {-3.60048*10^-6, 0., 0.}, {0., -3.60048*10^-6, 0.}}

deleted 78 characters in body
Source Link
Henrik Schumacher
  • 109.5k
  • 7
  • 186
  • 323

Suppose we have a MeshRegion that we want to export to an obj file with, say double precision. Is that possible with Export? And how would we do that? The documentation on "OBJ" does not list any options. I am asking explicitly about Export. Of course, I could write my own OBJ exporter, but this would be somewhat awkward. (I've actually done it already.)

The default seems to export only about 6 decimal digits as the following example is supposed to show:

R = MeshRegion[
   {{0., 0., 0.}, {Sqrt[2.], 0., 0.}, {0., Sqrt[2.], 0.}},
   Triangle[{{1, 2, 3}}]
   ];
file = FileNameJoin[{$TemporaryDirectory, "a.obj"}];
Export[file, R];
MeshCoordinates[Import[file]] - MeshCoordinates[R]

{{0., 0., 0.}, {-3.6004810^-6, 0., 0.}, {0., -3.6004810^-6, 0.}}

Btw.: Importing higher precision numbers with Import seems to work fine.

Suppose we have a MeshRegion that we want to export to an obj file with, say double precision. Is that possible with Export? And how would we do that? The documentation on "OBJ" does not list any options. I am asking explicitly about Export. Of course, I could write my own OBJ exporter, but this would be somewhat awkward. (I've actually done it already.)

The default seems to export only about 6 decimal digits as the following example is supposed to show:

R = MeshRegion[
   {{0., 0., 0.}, {Sqrt[2.], 0., 0.}, {0., Sqrt[2.], 0.}},
   Triangle[{{1, 2, 3}}]
   ];
file = FileNameJoin[{$TemporaryDirectory, "a.obj"}];
Export[file, R];
MeshCoordinates[Import[file]] - MeshCoordinates[R]

{{0., 0., 0.}, {-3.6004810^-6, 0., 0.}, {0., -3.6004810^-6, 0.}}

Btw.: Importing higher precision numbers with Import seems to work fine.

Suppose we have a MeshRegion that we want to export to an obj file with, say double precision. Is that possible with Export? And how would we do that? The documentation on "OBJ" does not list any options. I am asking explicitly about Export. Of course, I could write my own OBJ exporter, but this would be somewhat awkward. (I've actually done it already.)

The default seems to export only about 6 decimal digits as the following example is supposed to show:

R = MeshRegion[
   {{0., 0., 0.}, {Sqrt[2.], 0., 0.}, {0., Sqrt[2.], 0.}},
   Triangle[{{1, 2, 3}}]
   ];
file = FileNameJoin[{$TemporaryDirectory, "a.obj"}];
Export[file, R];
MeshCoordinates[Import[file]] - MeshCoordinates[R]

{{0., 0., 0.}, {-3.6004810^-6, 0., 0.}, {0., -3.6004810^-6, 0.}}

Source Link
Henrik Schumacher
  • 109.5k
  • 7
  • 186
  • 323

How to control floating point precision when `Export`ing to obj format?

Suppose we have a MeshRegion that we want to export to an obj file with, say double precision. Is that possible with Export? And how would we do that? The documentation on "OBJ" does not list any options. I am asking explicitly about Export. Of course, I could write my own OBJ exporter, but this would be somewhat awkward. (I've actually done it already.)

The default seems to export only about 6 decimal digits as the following example is supposed to show:

R = MeshRegion[
   {{0., 0., 0.}, {Sqrt[2.], 0., 0.}, {0., Sqrt[2.], 0.}},
   Triangle[{{1, 2, 3}}]
   ];
file = FileNameJoin[{$TemporaryDirectory, "a.obj"}];
Export[file, R];
MeshCoordinates[Import[file]] - MeshCoordinates[R]

{{0., 0., 0.}, {-3.6004810^-6, 0., 0.}, {0., -3.6004810^-6, 0.}}

Btw.: Importing higher precision numbers with Import seems to work fine.