Group Abstract Group Abstract

Message Boards Message Boards

Seeking 3D rendering of 2D Lissajous curve

Posted 3 years ago
POSTED BY: Dave K
9 Replies
Posted 3 years ago

First of all, THANKS AGAIN!

I had tried varying "w" through a bunch of values, and only ever got one "loop" at the top. But I guess I didn't try the right values!

I tried what you said, and it got me my vertical/horizontal nodes. I've attached my latest version, for the record. With that working, I'm going to go back to your original color and perspective parameters, and see how close I can get to the "3D" effect I was looking for.

Then I'll report back!

Attachments:
POSTED BY: Dave K
Posted 3 years ago

As to why the compiler didn't complain when I tried to execute the ParametricPlot3D code with the Lissajous3D definition missing, I have no idea :-)

Thought it might be helpful to comment on this. There isn't really a compiler in the common sense, and there is nothing directly analogous to static type checking. ParametricPlot3D was given two parameters and their ranges. It was given a "function" (an expression that looked like what you might think of as a function) that was being applied to those two parameters. That function (Lissajous3D), however, didn't have any rewrite/evaluation rules associated with it (because you hadn't evaluated the SetDelayed expression that "defined" the Lissajous3D "function"). So, ParametricPlot3D was just left with a bunch of stuff that it didn't know how to interpret as a plot, and so the resulting output just looked empty.

POSTED BY: Eric Rimbey
Posted 3 years ago
POSTED BY: Eric Rimbey
Posted 3 years ago
Attachments:
POSTED BY: Dave K
Posted 3 years ago

Okay, my apologies. I figured it out. There was no output because I had not pasted the Lissajous function definition in. After I did that (ahead of the other code) and then pressed shift-ENTER, I got the plot.

Progress! lol.

Let me try to experiment with this and get back to you.

Thanks!

POSTED BY: Updating Name
Posted 3 years ago
POSTED BY: Eric Rimbey
Posted 3 years ago

Thanks for this amazing reply!

At the risk of fearing that I'm wasting your valuable expertise on a newbie question, I'm not clear on where to apply this code in Mathematica. I tried:

File > New > Package/Script > WolframScript Script

and then pasted the contents in and pressed "Run All Code", but nothing happens. I realize the "right" approach here would be to start from the ground up and learn Mathematica, but if you can quick-start me, then I may be able to pull this off...!

Thanks in advance!

POSTED BY: Dave K
Posted 3 years ago

Oh, I forgot to comment on animation. I wasn't confident enough in what you wanted to try animating it, but creating an animation is fairly easy. You just create a list of the individual "frames" and apply ListAnimate to it. Or you can parameterize how each frame is created, and use Animate. Maybe just rotating the plot (or even just rotating the ViewPoint) will get you what you want. Or maybe it's the Lissajous parameters themselves that you want to vary. Creating the frames you want will be the main challenge--animating them is a cinch.

POSTED BY: Eric Rimbey
Posted 3 years ago

Here's an approach.

  • Make the Lissajous curve wrap around a cylinder (I'm assuming this will give the 3D shape you want, but if you're wanting something else, like an over-under knot type pattern, then this won't work--but something else will :) )
  • Use ParametricPlot3D
  • Use two parameters in the plot to create a ribbon
  • Use lighting or other styling to enhance the 3D effect.

Here's an example output: enter image description here

Here is the code for the ParametricPlot3D:

ParametricPlot3D[
 Lissajous3D[1, 1, 3, Pi/3][t, s],
 {s, 0, .1}, {t, 0, 2 Pi},
 ViewPoint -> Front,
 ViewProjection -> "Orthographic",
 ColorFunction -> (White &),
 MeshStyle -> None,
 PlotPoints -> {20, 60},
 Lighting -> {{"Point", Blue, {0, -5, 0}}, {"Point", 
    Green, {3, -5, 0}}},
 Axes -> False]

You can see the options I've used, and hopefully that will get you started. The documentation for each option should help you figure out how to get your preferred appearance.

Here's the definition for the Lissajous3D function:

Lissajous3D[cx_, cy_, w_, d_][t_, s_] := {cx Sin[t w + d], cx Cos[t w + d], cy Sin[t] + Rescale[cx Cos[t w + d], {-1, 1}, {s, .5 s}]}

The x and z coordinates plot the 2d lissajous, and the y coordinate the front/back distance as if it was wrapping around a cylinder. This may not be the exact 3d shape you want, but hopefully it'll get you started. You can switch the coordinates to change the orientation.

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard