Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006


C + + help ah.

#include<iostream>
#include<stdlib.h>
# X 0
Y # 1
FALSE # 1
True # 3
Tion # 2
Typedef int tPointi[DIM];
Typedef double tPointd[DIM];
Using namespace std;
Int main () (
Int SegSegInt (tPointi a, tPointi b, tPointi c, d tPointi, tPointd p);
Int int bo; Rifa
TPointi point1, point2, point3, point4;
TPointd point5;
Point5[X]=0.0;point5[Y]=0.0;
Point1[X]=1; point1[Y]=1;
Point2[X]=2; point2[Y]=3;
Point3[X]=1; point2[Y]=2;
Point4[X]=5; point4[Y]=2;
Bo=SegSegInt (point1, point2, point3, point4, point5); //point5 Below is the actual function parameters p Lane
Cout<<bo<<endl;
If (bo==3) cout<< "intersection" "" "(" "<point5[X]<<", "" <point5[Y]<< ")" "<endl; //point5 bring out p[x], p[y] right here ah?
Else cout<< "intersection" "<endl;
System ( "pause");
}
   
Int SegSegInt (tPointi a, tPointi b, tPointi c, d tPointi, tPointd p) (
Double s, tons.
Also published a double, denom;
Denom=a[X]* (d[Y]-c[Y]) +
B[X]* (c[Y]-d[Y]) +
D[X]* (b[Y]-a[Y]) +
C[X]* (a[Y]-b[Y]); //denom=8;
Cout<< "denom=" "<denom<<endl;
If (denom==0.0) return FALSE;
Num=a[X]* (d[Y]-c[Y]) +
C[X]* (a[Y]-d[Y]) +
D[X]* (c[Y]-a[Y]); //num=4;
Cout<< "num=" "<num<<endl;
S=num/denom;
Cout<< "s =" "<s<<endl; //s=0.5;
Num=- (a[X]* (c[Y]-b[Y]) +
B[X]* (a[Y]-c[Y]) +
C[X]* (b[Y]-a[Y])); 4003rd new calculation num=1;
Cout<< "num=" "<num<<endl;
T=num/denom; //t=1/8=0.125
Cout<< "t" "<t<<endl;
P[X]=a[X]+s* (b[X]-a[X]);
Cout<<p[X]<<endl;
P[Y]=a[Y]+s* (b[Y]-a[Y]);
Cout<<p[Y]<<endl;
If ((0.0<=s) & (s<=1.0) & (0.0<=t) & (t<=1.0)) return TRUE; 4003rd these conditions are met ah? Why main export or not Lane intersection
Else return FALSE;
}


Lane English teacher to a section of the code seems to be calculated, the two-phase intersection of the line. I point to coordinates given by Radio 4, the operating result was outrageous ah.
   
Denom=4.01313e+006;
Num=1.60525e+007
S=4
Num=4.01313e+006
T=0.999999
How possible heroes who help me ah, I have the N even more complicated than it should be emphasized that the day after teachers, it does help the Manga. Please!

Bo=SegSegInt (point1, point2, point3, point4, point5); Changed
Bo=SegSegInt (point1, point2, point3, point4, &point5); Try

Why?

If not!

Point1[X]=1; point1[Y]=1;
Point2[X]=2; point2[Y]=3;
Point3[X]=1; point2[Y]=2;
You here point3[X]=1; point2[Y]=2;
Point2 point3[X]=1; point3[Y]=2; your written into the point3

I see that you did not see, sorry. Just find that this is not correct point3[Y] initialization. The operation took place at the wrong time. If the address posted. Ha ha

Oh, well now. Hey, but also one of the annoyed.

What? Can be contacted me QQ6770334, learn from each other, huh, huh.



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com