header

Show all links

AutoHotkey | Android | Arduino | Ballarat Fire Brigade | Ballarat Weather | Cool Stickers | CorelDRAW | Deviantart | EDAR308 | EDFD127-167 | Electromagnetism  | Fractals | Google | Grammar Checkers | ICT leaders day | Lilypad & Flora | Markbook | NRSG137 | Pan and Tilt Heads | Photoshop CS3 | PintrestProcessing | Raspberry Pi | RedBubble | Slowmation | Tutorials | Weather | World Time Converter | Word Clouds | World Clock Meeting Planner |

Home > Tutorials > Processing > Processing Examples > Lissajous v37

Lissajous v37

Lissajous a=1 b=3

See http://en.wikipedia.org/wiki/Lissajous_curve

Lissajous Code

processing code

// Created with "Processing":http://processing.org/
// Draws a Lissajous figures
// 2 April 2011
// http://www.rupert.id.au/tutorials/processing/examples.php

int screen_width = 606;
int screen_height = 625;

/* Scale image and reduce by 5 pixels to remove from edge of screen */
int AX = (screen_width / 2) - 5;
int BX = (screen_height / 2) - 5;

float a = 1;
float b = 3;
float x1;
float y1;
float x2;
float y2;

int counter = 0;
int saveCounter = 0;
String file_name;

void setup(){
  smooth();
  fill(255);
  strokeWeight(1);   
  size(screen_width, screen_height);
  }

// Based on Microworlds LOGO code from http://www.mathcats.com/gallery/15wordcontest.html
// repeat 360 [setxy (sin(2 * repcount)) * 150 (sin(3 * repcount)) * 150] 

void draw(){
  fill(#000000);
  
  // Find 2 points and draw a line between them
  x1 = (sin(a * counter) * AX) + screen_width / 2;
  y1 = (sin(b * counter) * BX) + screen_height / 2;
  
  counter = counter + 1;
  x2 = (sin(a * counter) * AX) + screen_width / 2;
  y2 = (sin(b * counter) * BX) + screen_height / 2;
   
  line(x1,y1,x2,y2);
    
  saveCounter = saveCounter + 1;
  if (saveCounter == 365) {
    String file_name = "Lissajou_a=" + str(a) + "_b=" + str(b);
    save(file_name);
    noLoop();
  }
}
code formatter

 

code formatter

 


APA citation:
Russell, R. (2011, April 02, 10:24 am). Lissajous v37.
     Retrieved October 21, 2014, from http://www.rupert.id.au/tutorials/processing/examples/Lissajous/lissajou_v37.php

Last refreshed: October 21 2014. 02:39.59 pm

rupert dot russell at acu dot edu dot au Support Wikipedia

Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.


1116 visits since April 2, 2011