vendredi 10 février 2023

the power of Trigonometric functions!












اليوم اقدم برنامج يبين ما مدى اهمية الدوال الجيبية في محاكات حركة دوران عقرب الساعة مكتوب بلغة جافا , عدد اسطره لا يتجاوز 40 كما هو موضح ا


/* CLOCK */

PImage clock;
float rh,rm,rs;
float xh,yh,thetah;
float xm,ym,thetam;
float xs,ys,thetas;
void setup() {
size(600,600);
clock=loadImage("e:/processing/clock0.jpg");
rh = 80; rm = 120; rs = 160;
}
void draw() {
thetah = 2*PI*hour()/12-PI/2;
xh = rh* cos(thetah)+width/2; yh = rh* sin(thetah)+height/2;
thetam = 2*PI*minute()/(60)-PI/2;
xm = rm* cos(thetam)+width/2; ym = rm* sin(thetam)+height/2;
thetas = 2*PI*second()/(60)-PI/2;
xs = rs* cos(thetas)+width/2; ys = rs* sin(thetas)+height/2;
background(0);
image(clock,0,0);
textSize(20);
fill(0);
textAlign(CENTER);
text(hour()+":"+minute()+":"+second(),width/2,180);
stroke(0,0,255); strokeWeight(3);
line(width/2,height/2,xs,ys);
stroke(0,255,0); strokeWeight(5);
line(width/2,height/2,xm,ym);
stroke(255,0,0); strokeWeight(8);
line(width/2,height/2,xh,yh);
}

dimanche 27 novembre 2022

لعبة hockeyball بواسطة الشبكة !


















هذه اللعبة ستكون اول نموذج تعليمي بحيث سأقوم توضيح جميع الخطوات برمجة الالعاب من النقطة صفر الى مستوى الاعتراف , الدروس ستكون على شكل اجزاء متسلسلة , اشير في الاخير ان هذه الدروس موجهة لمن لديهم ادنى معرف عن البرمجة نظريا و الرياضيات مستوى ثانوي على الاقل
1/ اختيار لغة البرمجة المناسبة
2/ علاقة شاشة الكمبيوتر بالهندسة ثنائية الابعاد
3/ مفهوم الرسومات و تحويلها الى تعليمات رقمية
4/ مبدأ حركة الرسومات في الشاشة
5/ تفاعل الفأرة و لوحة المفاتيح مع الكمبيوتر
7/ فيزياء الحركة و اصطدام الرسومات
8/ ادارة الاحداث و توجيهها
9/ مبدأ الذكاء الاصطناعي و تطبيقاته في الالعاب
10/ برمجة العاب عن طريق شبكة LAN


 

mercredi 2 novembre 2022

double pendulum

 





float theta1,vtheta1,theta2,vtheta2;

float x1,y1,x2,y2;
float vx,vy;
float g=9.8;
float l= 4;
void init() {
theta1 =0; vtheta1 = 0.0;
theta2 =0; vtheta2 = 0.0;
//l= density*l;
}
void motion(float dt) {
float a= 2;
float b= cos(theta1-theta2);
float c= cos(theta1-theta2);
float d = 1;
float b1= vtheta1*vtheta2*sin(theta1-theta2)-2*g/l*sin(theta1)+ax*vx;
float b2 = -vtheta1*vtheta2*sin(theta1-theta2)-g/l*sin(theta2)+ay*vy;
float det = a*d-b*c;
float r1= (d*b1-b*b2)/det;
float r2= (-c*b1+a*b2)/det;
vtheta1+= dt*r1;
vtheta2+= dt*r2;
// vtheta1+= dt/l*(ax*cos(theta1)+sin(theta1)*(-g+ay));
// vphi+=dt/(l*sin(phi))*(ax*sin(phi)-ay*cos(phi));
theta1+= vtheta1*dt;
vtheta1*=0.98;
// vtheta2+= vtheta1+dt/l*(ax*cos(theta2)+sin(theta2)*(-g+ay));
theta2+= vtheta2*dt;
vtheta2*=0.98;
vx+=dt*ax;
vy+=dt*ay;
}
void pendulum() {
strokeWeight(10);
k=100;
float theta1,vtheta1,theta2,vtheta2;
float x1,y1,x2,y2;
float vx,vy;
float g=9.8;
float l= 4;
void init() {
theta1 =0; vtheta1 = 0.0;
theta2 =0; vtheta2 = 0.0;
//l= density*l;
}
void motion(float dt) {
float a= 2;
float b= cos(theta1-theta2);
float c= cos(theta1-theta2);
float d = 1;
float b1= vtheta1*vtheta2*sin(theta1-theta2)-2*g/l*sin(theta1)+ax*vx;
float b2 = -vtheta1*vtheta2*sin(theta1-theta2)-g/l*sin(theta2)+ay*vy;
float det = a*d-b*c;
float r1= (d*b1-b*b2)/det;
float r2= (-c*b1+a*b2)/det;
vtheta1+= dt*r1;
vtheta2+= dt*r2;
// vtheta1+= dt/l*(ax*cos(theta1)+sin(theta1)*(-g+ay));
// vphi+=dt/(l*sin(phi))*(ax*sin(phi)-ay*cos(phi));
theta1+= vtheta1*dt;
vtheta1*=0.98;
// vtheta2+= vtheta1+dt/l*(ax*cos(theta2)+sin(theta2)*(-g+ay));
theta2+= vtheta2*dt;
vtheta2*=0.98;
vx+=dt*ax;
vy+=dt*ay;
}
void pendulum() {
strokeWeight(10);
k=100;
x1=k*l*sin(theta1)+x0;
y1=k*l*cos(theta1)+y0;
x2=x1+k*l*sin(theta2);
y2=y1+k*l*cos(theta2);
stroke(255);
float k=1000;
stroke(255);
line(x0,y0,x1,y1);
line(x1,y1,x2,y2);
stroke(255,0,0);fill(255,255,0);
// ellipse(x1,y1,60,60);
fill(200,0,0);noStroke();
lights();
//ambientLight(0,0,0,0,-1,0);
lightSpecular(255,255,255);
directionalLight(200,100,100,-1,0,-1);
specular(200);
pushMatrix();
translate(x1,y1);
sphere(50);
popMatrix();
pushMatrix();
translate(x2,y2);
sphere(60);
popMatrix();
noFill();stroke(200);
ellipse(x0,y0,60,60);
ellipse(x0,y0,10,10);
}

Hologram


 

mardi 7 juin 2022

fastdraw64 tuto 7 clipping "fd_view"

 



#include "fastdraw.cpp"

image t800;

float  zoom = 0;

bool s = true;


void draw() {

zoom+=0.03;

float kx = 0.6*cos(zoom*0.05);

kx = kx*kx;

float ky = 3.14/3*cos(zoom*0.3);

     fd_clear(0,0,100);

  

     fd_view(200,100,700,600);

fd_image(t800,100*kx,100*ky);

 fd_view(100,250,900,600);

fd_image(t800,0,0,150,100);

fd_view(100,150,900,600);

fd_image(t800,120,80,250,250);

 fd_view(100,300,900,400);

fd_image(t800,120+350,80,450,300);

fd_view(300,200,400,700);

fd_image(t800,50,350,900,600);


fd_view(0,00,900,600);

        fd_image(t800,t800.bmWidth/2,t800.bmHeight/2,ky,kx,kx,100,200);

}


int main() {

t800 = fd_loadimage("c:/dos/t800.bmp");

       fd_window("fd64 tuto6 ",1000,800);

        fd_loop(draw);

return 0;

}



lundi 30 mai 2022

Camera Security using smartphone as camera ...written in processing

Laptop






SmartPhone



اقدم اليوم تطبيق من برامجي الخاصة CameraSecurity يقوم بمراقبة و تسجيل الفيديو عن بعد بواسطة شبكة الويفي و كل هذا لا يكلف درهما واحد سوى جهاز كمبيوتر pc او laptop و هاتف نقال خاص يعمل بدلا من كاميرا مراقبة ثمنها باهض حيث يمكنكم ان تضعوا هاتفكم في اي مكان و زاوية لبث مباشر على شاشة الفيديو في جهازكم الكمبيوتر من مكتبكم او اي مكان اخر

mercredi 18 mai 2022

fastdraw64 tuto6 rotate & scale

 



#include "fastdraw.cpp"

BITMAP t800;

float  zoom = 0;

bool s = true;

void draw() {

zoom=zoom+0.03;

float kx = sin(zoom*0.05);

kx = kx*kx;

float ky = 3.14/3*cos(zoom*0.3);

      fd_clear(0,0,100);

            fd_image(t800,t800.bmWidth/2,t800.bmHeight/2,ky,kx,kx,100,200);

 



}


int main() {

t800 = fd_loadimage("c:/dos/t800.bmp");

        fd_window("fd64 tuto4 ",1000,800);

       fd_loop(draw);

return 0;

}