မဂၤလာပါခင္ဗ်ာ


ဧည့္သည္ေတာ္မ်ားကိုယ္စိတ္ႏွစ္ျဖာက်မ္းမာရႊင္လန္းၾကပါေစခင္ဗ်ာ။

C++ အိမ္စာမ်ား(၁၃)

ဒီတစ္ခါ တင္ဆက္မွာကေတာ့ စက္၀ိုင္းတစ္ခုနဲ႔ မ်ဥ္းတစ္ေၾကာင္းတို႔ ဘယ္မွာျဖတ္မလဲဆိုတာကို ရွာဖို႔ပါေရးထားတာကိုပဲ ေအာက္မွာျပထားတဲ့ ပံုသံုးပံုနဲ႔ တိုက္စစ္ျပပါမယ္ခင္ဗ်ာ
ဒီသံုးပံုမွာ နမူနာအျဖစ္ စက္၀ိုင္းေတြကို စင္တာမွတ္ (0,0) နဲ႔ အခ်င္း၀က္ ၅ ထားလိုက္ပါတယ္။ အနီေရာင္နဲ႔ျပထားပါတယ္။ အျပာေရာင္လိုင္းကို ထုတ္ေပးမယ့္ အမွတ္ေတြကို အျပာနဲ႔ျပျပီး၊ ျဖတ္မွတ္အေျဖေတြကိုေတာ့ အစိမ္းနဲ႔ျပထားပါတယ္။

ထည့္ေပးရမယ့္အမွတ္ေတြက စက္၀ိုင္း ဗဟို (xy coordinate )အတြက္ a နဲ႔ b အခ်င္း၀က္ r မ်ဥ္းေၾကာင္းအတြက္ စမွတ္ ဆံုးမွတ္ xy coordinate ႏွစ္စံုတို႔ျဖစ္ပါတယ္။

ထုတ္ေပးမယ့္အေျဖက ျဖတ္ရင္ ဘယ္အမွတ္မွာ ျဖတ္မယ္ဆိုတာနဲ႔ မျဖတ္ရင္ မျဖတ္ဘူးပါ။

နမူနာသံုးပံုမွာေတာ့ ပထမပုစၦာအတြက္ ႏွစ္ေနရာျဖတ္လို႔ ႏွစ္မွတ္ ထုတ္ေပးရပါမယ္။
ဒုတိယပုစၦာအတြက္ တစ္ေနရာပဲ ျဖတ္လို႔ တစ္မွတ္သာထုတ္ေပးဖို႔လိုျပီး၊ တတိယပုစၦာမွာေတာ့ ျဖတ္မွတ္မရွိေၾကာင္းအေျဖေပးႏိုင္ရမွာျဖစ္ပါတယ္။

အဲဒီပုစၦာသံုးပုဒ္အတြက္ အေျဖေတြကေတာ့ ...
(၁) ႏွစ္မွတ္အေျဖထုတ္ေပးပါတယ္။ အေပၚက ပံုနဲ႔ ယွဥ္တြဲၾကည့္ႏိုင္ပါတယ္။
(၂)ျဖတ္မွတ္ တစ္မွတ္သာရွိပါတယ္။ ပံုနဲ႔တြဲၾကည့္ပါ။
(၃) ျဖတ္မွတ္မရွိပါခင္ဗ်ာ။ ယာဘက္ဆံုးပံုအတိုင္းျဖစ္ပါတယ္။
ပရိုပရမ္မွာ အဓိကသံုတာေတြကေတာ့
မ်ဥ္အီေကြရွင္းျဖစ္တဲ့   y=mx+c နဲ႔ m=(y2-y1)/(x2-x1) တို႔နဲ႔အတူ၊
စက္၀ိုင္းအီေကြရွင္းျဖစ္တဲ့ (x-a)^2+(y-b)^2=r^2 တို႔ကိုသံုးထားတာျဖစ္ပါတယ္။
ပရိုဂရမ္အရေတာ့ မရႈပ္ပါဘူး။ သခၤ်ာအေတြးက အဓိကပါ။

အလွ်ားလိုက္မ်ဥ္းအတြက္ slope က 0 ျဖစ္လို႔ ျပႆနာမျဖစ္ေပမယ့္၊ ေဒါင္းလိုက္မ်ဥ္းမွာေတာ့ slope က ျပႆနာေပးပါေတာ့တယ္။ m=(y2-y1)/0 ျဖစ္လို႔ပါ။ အဲဒီျပႆနာအတြက္ ကြၽန္ေတာ္ ၂ ဆေရးလိုက္ရပါတယ္။ ေက်ာင္းသားမ်ားအေနနဲ႔ ဖတ္ရလြယ္ကူေအာင္လို႔ အမွတ္ေတြကို အတတ္ႏိုင္ဆံုးသီးသန္႔ ခြဲျခားေရးေပးလိုက္ပါတယ္။ ေနာင္မွာလည္း ဆက္လက္ေရးေပးပါဦးမယ္။ ကြၽန္ေတာ္ဆီမွာ စိတ္၀င္စားစရာပရိုဂရမ္ေတြ က်န္ပါေသးတယ္ခင္ဗ်ာ။

#include <iostream.h>
#include <conio.h>
#include <math.h>
void main()
{
double  a,b,r,x1,y1,x2,y2,m,c,i,j,k,d,x11,y11,x22,y22,x,y;
cout<<"General equation of circle: (x-a)*(x-a)+(y-b)*(y-b)=r*r";cout<<endl;
cout<<"Generel equation of line: y=m*x+c where m=(y2-y1)/(x2-x1)";cout<<endl;cout<<endl;
cout<<"x-coordinate of center of circle a=";cin>>a;cout<<endl;
cout<<"y-coordinate of center of circle b=";cin>>b;cout<<endl;
cout<<"radius of circle r=";cin>>r;cout<<endl;
cout<<"x-coordinate of first point  of line x1=";cin>>x1;cout<<endl;
cout<<"y-coordinate of first point  of line y1=";cin>>y1;cout<<endl;
cout<<"x-coordinate of second point  of line x2=";cin>>x2;cout<<endl;
cout<<"y-coordinate of second point  of line y2=";cin>>y2;cout<<endl;
if ((x2-x1)==0)
{  x=x1;
   i=1;
   j=(-2*b);
   k=x*x-2*a*x+a*a+b*b-r*r;
   d=j*j-(4*i*k);
   cout<<"Equation of the given line:"<<"x="<<x;cout<<endl;
   cout<<"Equation of given circle: (x-"<<a<<")*(x-"<<a<<")+(y-"<<b<<")*(y-"<<b<<")="<<r*r;cout<<endl;cout<<endl;



   if (d>0)
   {y11=(-j+sqrt(d))/(2*i);
   y22=(-j-sqrt(d))/(2*i);
   x11=x;
   x22=x;
   cout<<"Coordinate of first point  of intersection= ("<<x11<<","<<y11<<")";cout<<endl;
   cout<<"Coordinate of second point  of intersection= ("<<x22<<","<<y22<<")";cout<<endl;}

   if (d==0)
   {y=(-j)/(2*i);
    cout<<"Coordinate of point  of intersection= ("<<x<<","<<y<<")";cout<<endl;}

    if (d<0)
    {cout<<"No point of intersection";}
}
else
{   if (d>0)
    m=(y2-y1)/(x2-x1);
    c=y1-m*x1;
    cout<<"Equation of the given line:"<<"y="<<m<<"*x+"<<c;cout<<endl;
    cout<<"Equation of given circle: (x-"<<a<<")*(x-"<<a<<")+(y-"<<b<<")*(y-"<<b<<")="<<r*r;cout<<endl;cout<<endl;

    i=(1+m*m);
    j=(-2*a+2*m*c-3*b*m);
    k=a*a-2*c*b+b*b+c*c-r*r;
    d=j*j-(4*i*k);

    if (d>0)
    {x11=(-j+sqrt(d))/(2*i);
    x22=(-j-sqrt(d))/(2*i);
    y11=m*x11+c;
    y22=m*x22+c;
    cout<<"Coordinate of first point  of intersection= ("<<x11<<","<<y11<<")";cout<<endl;
    cout<<"Coordinate of second point  of intersection= ("<<x22<<","<<y22<<")";cout<<endl;}

    if (d==0)
    {x=(-j)/(2*i);
    y=m*x+c;
    cout<<"Coordinate of point  of intersection= ("<<x<<","<<y<<")";cout<<endl;}
  
    if (d<0)
    {cout<<"No point of intersection";}

}
getch();
}

Comments :

0 comments to “C++ အိမ္စာမ်ား(၁၃)”

Post a Comment

 

သြားလည္တတ္တဲ့ဖိုရမ္ေတြက

Subscribe Subscribe Subscribe

ေတာင္းပန္စကား

ငါတတ္ငါေတာ္ ငါအေက်ာ္ဟု၊ ငါေသာ္စိတ္ထား မရွိျငားလည္း၊ ငါကားငယ္ရြယ္ ဥာဏ္မၾကြယ္၍၊ အဘယ္သုိ႔လွ်င္ အမွားစင္အံ့၊ အၾကင္သူေတာ္ ပညာေက်ာ္သည္၊ ခၽြတ္ေခ်ာ္လြဲမွား ငါ့စကားကုိ၊ စိတ္ထားေဖြးျဖဴ ျပင္ေတာ္မူ။ (ရွင္အဂၢဥာဏ)

အေမာင့္ကိုေျပာခဲ့ခ်င္ရင္

လာလည္ၾကသူမ်ား

လာလည္ၾကၾကိမ္ေပါင္း

ဖတ္ၾကတဲ့ စာမ်က္ႏွာအေရအတြက္