Originally Posted by
grumpy
We already know what you want.
Read the site's homework policy,
here. This is not a free code factory. If you want help, demonstrate a genuine effort to solve your problem on your own - with code. Then people might consider helping you with specific problems you have encountered.
But, then again, from your behaviour, what you seek is someone to write the code for you, rather than doing it yourself. That won't happen.
Today i tried following is my code :
Code:
#include<stdio.h>
#include<math.h>
int intersection(float,float,float,float,float,float,float,float);
int main()
{
int x1,y1,a1,b1,x2,y2,a2,b2;
int ret;
// ret=intersection(x1,y1,a1,b1,x2,y2,a2,b2);
ret=intersection(2,2,2,1,7,2,2,1);
if(ret==1)
printf("Two ellipses are intersect\n");
else
printf("Two ellipses are not intersect\n");
return 0;
}
int intersection(float x1,float y1,float a1,float b1,float x2,float y2,float a2,float b2)
{
float x,y;
float z;
x=(1/(a2*b1-a1*b2)*(a2*b1-a1*b2))*(-sqrt(-(a1*a1*a2*a2)*(y1-y2)*(y1-y2)*(a2*b1-a1*b2)*(a2*b1-a1*b2)));
y=(1/(a2*b1-a1*b2)*(a2*b1-a1*b2))*((a1*a1*b2*b2*x2)-(a1*a2*b1*b2*x1)-(a1*a2*b1*b2*x2)+(a2*a2*b1*b1*x1));
z=(1/(a2*b1-a1*b2)*(a2*b1-a1*b2));
printf("result of intersection is %f and %f and %f",x,y,z);
return 1;
}
after compiling it giving following output:
result of intersection is -nan and -nan and -nanTwo ellipses are intersect
I am getting -nan as output why i am not understand
please help me