11

This came up in a different context but some expertise in 3D surfaces or the graphic options would be appreciated. I'm trying to extrapolate the curves from any given surface and things seem to be going quite smoothly. All the curves can be grabbed in one more step as a GraphicsComplex. Perfect for more processing. However, now I'm trying to rotate the isolines to get even more control. This is possible in other software but I'm not sure how it was achieved. I assume there is some way to use the MeshFunction to rotate the Mesh through at least 45 degrees but all my searching hasn't brought up anything helpful. A less practical approach might be to find the intersecting curve of a regularly spaced vertical planes.

Plot3D[Cos[(x y)/2], {x, 0, 4}, {y, 0, 8},
BoxRatios->{4,8,1},
Boxed->False,
Axes->False,
ImageSize->Large,
Mesh->{3,8},
PlotStyle->Directive[Lighting->"Neutral",FaceForm[White,Specularity[0.2,10]]]]

enter image description here

enter image description here

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
BBirdsell
  • 1,196
  • 8
  • 21

2 Answers2

13

Since we have the identity

RotationMatrix[θ] == {AngleVector[-θ], AngleVector[π/2 - θ]}

one can use this to construct a mesh that is arbitrarily oriented; e.g.

Manipulate[Plot3D[Cos[x y/2], {x, 0, 4}, {y, 0, 8}, BoxRatios -> Automatic, 
                  MeshFunctions -> {AngleVector[-θ].{#, #2} &,
                                    AngleVector[π/2 - θ].{#, #2} &},
                  PlotStyle -> Directive[Lighting -> "Neutral",
                                         FaceForm[White, Specularity[0.2, 10]]]],
           {θ, 0, 2 π}]

Manipulate demo

Note that this rotates the mesh clockwise; use MeshFunctions -> {AngleVector[θ].{#, #2} &, AngleVector[π/2 + θ].{#, #2} &} instead if the anticlockwise version is desired.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
7

You can use MeshFunctions -> (Function /@ (RotationMatrix[θ].{#, #2})) to rotate by angle θ:

θ = 75 Degree;
meshfunctions = Function /@ (RotationMatrix[θ].{#, #2});

Plot3D[Cos[x y/2], {x, 0, 4}, {y, 0, 8}, 
 MeshFunctions -> meshfunctions, Mesh -> {3, 8},
 BoxRatios -> {4, 8, 1}, Boxed -> False, Axes -> False, 
 ImageSize -> Large, 
 PlotStyle -> Directive[Lighting -> "Neutral", FaceForm[White, Specularity[0.2, 10]]]]

enter image description here

For 45 Degree rotation you can use the simpler MeshFunctions -> {# + #2 &, # - #2 &} to get

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896