Smart Table for Dining
實作:數位餐桌
PVector[] dish=new PVector[4];
void setup(){
size(640,480);
dish[0]=new PVector(100,100); ←小盤子的位置
dish[1]=new PVector(540,100);
dish[2]=new PVector(100,380);
dish[3]=new PVector(540,380);
}
void draw(){
background(255);
ellipse(320,240,400,400);//rotating circle
ellipse(100,100,100,100); ←大盤子的位置
ellipse(540,100,100,100);
ellipse(100,380,100,100);
ellipse(540,380,100,100);
for(int i=0;i<4;i++){
ellipse(dish[i].x,dish[i].y,90,90);
}
}
int nowDish=-1;
void mousePressed(){
for(int i=0;i<4;i++){
if(dist(dish[i].x,dish[i].y,mouseX,mouseY)<45){
nowDish=i;
}
}
}
void mouseDragged(){
if(nowDish!=-1)
dish[nowDish].x=mouseX; ←滑鼠移動盤子
dish[nowDish].y=mouseY;
}
void mouseReleased(){
nowDish=-1;
}



![]() |
拖拉盤子會有角度線 |
![]() |
按任意鍵盤子會旋轉 |
PVector[] dish=new PVector[4];
float[]r={0,0,0,0};
float[]angle={0,0,0,0};
void setup(){
size(640,480);
dish[0]=new PVector(100,100);
dish[1]=new PVector(540,100);
dish[2]=new PVector(100,380);
dish[3]=new PVector(540,380);
}
void draw(){
background(255);
ellipse(320,240,400,400);//rotating circle
ellipse(100,100,100,100);
ellipse(540,100,100,100);
ellipse(100,380,100,100);
ellipse(540,380,100,100);
for(int i=0;i<4;i++){
ellipse(dish[i].x,dish[i].y,90,90);
line(dish[i].x,dish[i].y,320,240);
}
if(keyPressed){
for(int i=0;i<4;i++){
angle[i]-=0.01;
dish[i].x=r[i]*cos(angle[i])+320;
dish[i].y=r[i]*sin(angle[i])+240;
}
}
}
int nowDish=-1;
void mousePressed(){
for(int i=0;i<4;i++){
if(dist(dish[i].x,dish[i].y,mouseX,mouseY)<45){
nowDish=i;
}
}
}
void mouseDragged(){
if(nowDish!=-1)
dish[nowDish].x=mouseX;
dish[nowDish].y=mouseY;
r[nowDish]=sqrt((mouseX-320)*(mouseX-320)+(mouseY-240)*(mouseY-240));
angle[nowDish]=atan2(mouseY-240,mouseX-320);
}
void mouseReleased(){
nowDish=-1;
}
*開車
https://www.facebook.com/162587530761269/videos/302527540100600/?hc_location=ufi
實作:停車


![]() |
車子可以前進、後退、左轉、右轉 |
void setup(){
size(640,480,P3D);
rectMode(CENTER);
}
float carX=640/2,carY=320/2;
float carDir=0.6,caeWheel=0;
void drawCar(){
translate(carX,carY);
rotateZ(carDir);
rect(0,0,187,89);
if(keyPressed&&keyCode==UP){
carX+=cos(carDir);carY+=sin(carDir);
}
else if(keyPressed&&keyCode==DOWN){
carX-=cos(carDir);carY-=sin(carDir);
}
else if(keyPressed&&keyCode==RIGHT){
carDir+=0.01;
}
else if(keyPressed&&keyCode==LEFT){
carDir-=0.01;
}
}
void draw(){
background(100);
drawCar();
}
void keyPressed(){
}



![]() |
調整前輪作轉彎 |
void setup() {
size(640, 480, P3D);
rectMode(CENTER);
}
float carX=640/2, carY=320/2;
float carDir=0.6, carWheel=0;
void drawCar() {
pushMatrix();
translate(carX, carY);
rotateZ(carDir);
rect(0, 0, 187, 89);
drawWheel(127/2,89/2,1);
drawWheel(127/2,-89/2,1);
drawWheel(-127/2,89/2,0);
drawWheel(-127/2,-89/2,0);
if (keyPressed&&keyCode==UP) {
carX+=cos(carDir+carWheel);carY+=sin(carDir+carWheel);
carDir+=carWheel/50;
} else if (keyPressed&&keyCode==DOWN) {
carX-=cos(carDir+carWheel);carY-=sin(carDir+carWheel);
carDir-=carWheel/50;
} else if (keyPressed&&keyCode==RIGHT) {
carWheel+=0.01;
if (carWheel>0.3) carWheel=0.3;
} else if (keyPressed&&keyCode==LEFT) {
carWheel-=0.01;
if (carWheel<-0.3) carWheel=-0.1;
}
popMatrix();
}
void drawWheel(float x,float y,int front) {
pushMatrix();
translate(x,y);
if(front==1) rotateZ(carWheel);
rect(0,0,40,20);
popMatrix();
}
void draw() {
background(100);
drawCar();
}
void keyPressed() {
}
*VR
用 HoloLens 加上空拍機, 學習太極拳
https://www.youtube.com/watch?v=KtVltAT7a-U&feature=youtu.be
故宮山水畫
https://youtu.be/MNuMH_OvptU
敦煌石窟
https://youtu.be/O3ZZCGgLgJM
*PowerPoint 的快速鍵
1. F5 播放
2. 播放時, 按 W 會變 White白色, 按 B 會變成 Black黑色
3. 直接按數字後再敲 Enter, ex. 按 11 Enter 就會跳到第 11頁
4. 可以用畫筆來畫
1. F5 播放
2. 播放時, 按 W 會變 White白色, 按 B 會變成 Black黑色
3. 直接按數字後再敲 Enter, ex. 按 11 Enter 就會跳到第 11頁
4. 可以用畫筆來畫
rectMode()
沒有留言:
張貼留言