-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCartesianSystem.py
More file actions
29 lines (28 loc) · 1006 Bytes
/
CartesianSystem.py
File metadata and controls
29 lines (28 loc) · 1006 Bytes
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
import math
class point:
def __init__(self,x,y):
self.x=x
self.y=y
class line:
def __init__(self,point1,point2,angle=None,c=None,m=None):
if (point2.x-point1.x)!=0 and angle==None and c==None and m==None:
self.slope=(point2.y-point1.y)/(point2.x-point1.x)
self.intercept=point1.y-(self.slope*point1.x)
elif point1.x==point2.x:
self.slope = "infinite"
self.intercept=point1.x
else:
if c==None and angle == 90:
self.slope = "infinite"
self.intercept=point1.x
else:
if m==None:
self.slope=math.tan(math.radians(angle))
else:
self.slope=m
self.intercept=c
def equation(line,point3):
if line.slope=="infinite":
return point3.x==line.intercept
else:
return point3.y==(((line.slope)*point3.x)+line.intercept)