Advertisement
alikimoko

"Correct" Lissajous figure creator

Jul 13th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {
  2. //By ajusting these pareters you can create all kinds of Lissajous figures. Just like the ones you get with a calculator.
  3.  
  4. corners = 360; //Increse for larger figures.
  5. x_centre = room_width/2; //X-coordinate of the centre.
  6. y_centre = room_height/2; //Y-coordinate of the centre.
  7. x_amplitude = 300; //How far on the x-axis goes the figure from the centre.
  8. y_amplitude = 300; //How far on the y-axis goes the figure from the centre.
  9. x_rotations_per_cycle = 1; //How often does the figure go across the x-axis per cycle. Do not set to 0. Using non round numbers result in unfinished figures
  10. y_rotations_per_cycle = 1; //How often does the figure go across the y-axis per cycle. Do not set to 0. Same ratios give the same figure.
  11. x_period = 0; //Does the figure begin at the centre (0) or somewhere else (below 2*pi). Setting these just right also results in unfinished figures.
  12. y_period = 0; //Does the figure start at the centre (0) or somewhere else (below 2*pi).
  13. x_direction = 1; //At the beginning, does the figure go right(1) or left (-1)
  14. y_direction = -1; //At the beginning, does the figure go up (-1) or down (1).
  15. thickness = 2; //The tickness of the outline.
  16. cycle_runrhrough = 1; //How often hould the cycle be run.
  17.  
  18.  
  19. for(i=1; i<(x_rotations_per_cycle*y_rotations_per_cycle*cycle_runrhrough*corners); i=i+1){
  20. draw_line_width(x_centre+x_amplitude*x_direction*sin(x_rotations_per_cycle*(x_period + 2*pi)*(i/(x_rotations_per_cycle*y_rotations_per_cycle*corners))), y_centre+y_amplitude*y_direction*sin(y_rotations_per_cycle*(y_period + 2*pi)*(i/(x_rotations_per_cycle*y_rotations_per_cycle*corners))), x_centre+x_amplitude*x_direction*sin(x_rotations_per_cycle*(x_period + 2*pi)*((i+1)/(x_rotations_per_cycle*y_rotations_per_cycle*corners))), y_centre+y_amplitude*y_direction*sin(y_rotations_per_cycle*(y_period + 2*pi)*((i+1)/(x_rotations_per_cycle*y_rotations_per_cycle*corners))), thickness);
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement