LoginSignup
4
4

More than 5 years have passed since last update.

【Processing】ロータリーエンジンのスクリーンセーバーをProcessingでつくる

Posted at

随分前に作ったので
解説ができませんが・・・

MAZDAロータリーエンジンの仕組みのスクリーンセーバーを作ってみました。

コピペで作れます。

roter.pde
int rt_cx;    //rotery center x
int rt_cy;    //rotery center y

int base_r;
int ig_r;    //inner gear radius
int st_r;    //stationally gear radius
int di_r;    //difference between ig_r and st_r

float rot_cen_posx,rot_cen_posy;  //rotation center point


float base_rt=1;  //base rotatetion degree volume
float now_rt;    //now rotation degree

float r;

float pi=3.14159265358979;

int i;

float dw,dh,smer;      //smer=smaller

int s;
int m;
int h;
String t;

void setup(){
  dw=displayWidth;
  dh=displayHeight;

  if(dw>=dh){
    smer=dh;
    base_r=(int) (smer/13.5);

    ig_r=base_r*3;  st_r=base_r*2; di_r=base_r;
    r=7.5*base_r;
    now_rt=0;
    rt_cx=displayWidth/2-st_r; rt_cy=displayHeight/2-st_r;
  }

  else if(dw<dh){
    smer=dw;
    base_r=(int) (smer/13.5);

    ig_r=base_r*3;  st_r=base_r*2; di_r=base_r;
    r=7.5*base_r;
    now_rt=0;
    rt_cx=displayWidth/2-st_r; rt_cy=displayHeight/2-st_r;
  }

  size(displayWidth,displayHeight);
  background(0);
  frameRate(60);
  noFill();




}

void draw(){



  rtt();

  s = second();
  m = minute();
  h = hour();
  t = nf(h, 2) + ":" + nf(m, 2) + ":" + nf(s, 2);
  text(t, dw-(smer/18)*5,dh-(smer/18)-20, (smer/18)*6, (smer/18)+20);

}

void rtt()
{
  background(0);
  noFill();
  strokeWeight(4);
  stroke(#FFFFFF);

  rot_cen_posx = rt_cx;
  rot_cen_posy = rt_cy;
  now_rt+=(base_rt*3);



  ellipse(rt_cx+st_r,rt_cy+st_r,st_r*2,st_r*2);    //stationally gear
  ellipse(rt_cx+st_r+di_r*cos((now_rt*3)*pi/180) , rt_cy+st_r+di_r*sin((now_rt*3)*pi/180) , ig_r*2 , ig_r*2);    //inner gear
  ellipse(rt_cx+st_r , rt_cy+st_r , di_r*2 , di_r*2 );    //excentric gear


  arc(rt_cx+st_r+di_r*cos((now_rt*3)*pi/180)+r*cos((now_rt+240)*pi/180) , rt_cy+st_r+di_r*sin((now_rt*3)*pi/180)+r*sin((now_rt+240)*pi/180) , r*cos(30*pi/180)*4, r*cos(30*pi/180)*4, ((now_rt+30)/180)*pi , ((now_rt+90)/180)*pi);    //roter line 1
  arc(rt_cx+st_r+di_r*cos((now_rt*3)*pi/180)+r*cos((now_rt+0)*pi/180) , rt_cy+st_r+di_r*sin((now_rt*3)*pi/180)+r*sin((now_rt+0)*pi/180) , r*cos(30*pi/180)*4, r*cos(30*pi/180)*4, ((now_rt+150)/180)*pi , ((now_rt+210)/180)*pi);    //roter line 1
  arc(rt_cx+st_r+di_r*cos((now_rt*3)*pi/180)+r*cos((now_rt+120)*pi/180) , rt_cy+st_r+di_r*sin((now_rt*3)*pi/180)+r*sin((now_rt+120)*pi/180) , r*cos(30*pi/180)*4, r*cos(30*pi/180)*4, ((now_rt+270)/180)*pi , ((now_rt+330)/180)*pi);    //roter line 1

  i=0;

  while(i<1080){        //roter housing
    point(rt_cx+st_r+di_r*cos((i)*pi/180)+r*cos((i)*pi/540) , rt_cy+st_r+di_r*sin(i*pi/180)+r*sin((i)*pi/540));
    i++;
  }
}

詳しくは
山本ワールド
http://yamatyuu.net/
http://yamatyuu.net/car/new_engin/rota.html
に載っています

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4