-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlineclass.cs
More file actions
64 lines (64 loc) · 1.82 KB
/
lineclass.cs
File metadata and controls
64 lines (64 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
namespace graphicsengine
{
class line
{
public point A;
public point B;
public char spcecialchar=' ';
public line(point aa, point bb,char fillchar=' '){
A = aa;
B = bb;
spcecialchar = fillchar;
}
public line( double x1, double y1, double x2, double y2, char fillchar=' '){
A = new point(x1,y1);
B = new point(x2,y2);
spcecialchar = fillchar;
}
public point getuper(){
point res=B;
if(A.Y>B.Y){
res = A;
}
return res;
}
public point getlower(){
point res=B;
if(A.Y<B.Y){
res = A;
}
return res;
}
public point getrightmost(){
point res=B;
if(A.X>B.X){
res = A;
}
return res;
}
public point getleftmost(){
point res=B;
if(A.X<B.X){
res = A;
}
return res;
}
public double gethorizontalintersection(double y){ ///should this return a point?
double res=-1;
if(getrightmost().X-getleftmost().X==0){
res = getrightmost().X;
} else{
double dir = (getrightmost().Y-getleftmost().Y)/(getrightmost().X-getleftmost().X);
double cst = A.Y-(dir*A.X);
res = (y-cst)/dir;
}
return res ;
}
public double getverticalintersection(double x){ ///should this return a point?
double dir = (getrightmost().Y-getleftmost().Y)/(getrightmost().X-getleftmost().X);
double cst = A.Y-(dir*A.X);
return (dir*x)+cst;
}
}
}