Parametric Equations / 媒介変数表示

媒介変数表示(パラメトリック方程式)とは、x座標とy座標の両方が別の文字で記述されている場合です。これはパラメータと呼ばれ、通常は文字tまたはθで表されます。Alexander MillerのYouTubeチャンネルからインスピレーションを得ました。

parametric equation geometry
Math

View Source Code

/*
 * @name Parametric Equations
 * @arialabel Black vertical lines travel in a spiral pattern in a 3D space
 * @description A parametric equation is where x and y
 * coordinates are both written in terms of another letter. This is
 * called a parameter and is usually given in the letter t or θ.
 * The inspiration was taken from the YouTube channel of Alexander Miller.
 */

function setup(){
  // createCanvas(720,400);
  createCanvas(windowWidth, windowHeight);
}

// the parameter at which x and y depends is usually taken as either t or symbol of theta
let t = 0;
function draw(){
  background('#fff');
  translate(width/2,height/2);
  stroke('#0f0f0f');
  strokeWeight(1.5);
  //loop for adding 100 lines
  for(let i = 0;i<100;i++){
    line(x1(t+i),y1(t+i),x2(t+i)+20,y2(t+i)+20);
  }
  t+=0.15;
}
// function to change initial x co-ordinate of the line
function x1(t){
  return sin(t/10)*125+sin(t/20)*125+sin(t/30)*125;
}

// function to change initial y co-ordinate of the line
function y1(t){
  return cos(t/10)*125+cos(t/20)*125+cos(t/30)*125;
}

// function to change final x co-ordinate of the line
function x2(t){
  return sin(t/15)*125+sin(t/25)*125+sin(t/35)*125;
}

// function to change final y co-ordinate of the line
function y2(t){
  return cos(t/15)*125+cos(t/25)*125+cos(t/35)*125;
}

License

Source code is available on GitHub p5.js website legacy.

All examples are licensed under CC BY-NC-SA 4.0.