Intersection of Random Two Lines From a Set of N Lines
Submitted by ashine1980 on Tuesday, September 8, 2015 - 11:42.
Language
This project will teach you how to get intersection of random two lines from a set of N lines. It was created using C/C++. This is very easy to do project. Download the project to see the full source code/
Please don't forget to like my page.
- #include<stdio.h>
- #include<ctype.h>
- #include<conio.h>
- #include<stdlib.h>
- int i=0;
- int a1=0 , b1=0 ,c1=0;
- int detA =0 , det1 =0 , det2=0 ; int l1=0 ,l2=0;
- float x=0,y=0 ; int lines ;int p=0,q=0,r=0,s=0;
- struct COF {
- int a =0,b=0,c=0,k=0;
- int count =0;
- struct COF *next;
- };
- COF AccessLine(COF *A,int m)
- {
- do
- {
- if(A->count==m-1) { return *A; }
- else { A=A->next ; }
- }
- while(A->next->count!=1);
- }
- int main(void)
- {
- struct COF *P;
- struct COF *REF;
- REF=P;
- for ( i=0;i<lines ; i++ )
- {
- P->a=a1; P->b=b1;P->c=c1 ;P->k=-1*c1;P->count=i;
- a1=0 ; b1=0 ;c1=0;
- if(i==lines-1) { P->next=REF;}
- }
- P=REF;
- *LINE1=AccessLine(P,l1);
- P=REF;
- *LINE2=AccessLine(P,l2);
- detA= LINE1->a*LINE2->b - LINE1->b*LINE2->a;
- det1=LINE1->a*LINE2->k - LINE2->a*LINE1->k ;
- det2=LINE2->b*LINE1->k - LINE1->b*LINE2->k;
- x=float(det2)/float(detA);
- y=float(det1)/float(detA);
- return(0);
- }
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Add new comment
- 23 views