Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I've been trying to export a Plot3D into an X3D (JVX, VRML) file using the Mathematica's Export function. The problem is that when the PlotRange is large compared to the other two dimensions the output is essentially stretched into a thin line. Is there a way to maintain the original scaling?

Try the following:

Export["file.x3d", Plot3D[x^2+y^2,{x,-10,10},{y,-10,10}]];

The VerticalAxis option does not seem to help...

Thanks.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

The "original scaling" of the displayed plot in Mathematica is determined by the BoxRatios setting for the plot, so it isn't intrinsic to the surface you're trying to export. When you export the plot, only the mesh is kept, with its actual 3D coordinates and without the scaling due to BoxRatios.

Therefore, if you want to export the surface in a "squished" form, you'll have to do the squishing yourself:

p = Plot3D[x^2+y^2,{x,-10,10},{y,-10,10}];
With[{zScale = .05},
 Export["squishedPlot.wrl", 
  p /. Graphics3D[gr_, opts___] :> 
    Graphics3D[
     GeometricTransformation[gr, ScalingTransform[{1, 1, zScale}]], 
     opts]]
 ]

I checked that this produces the desired "aspect ratio" by importing the file into Blender.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.