forked from Jus973/baseball-hit-trax
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphableLine.java
More file actions
89 lines (81 loc) · 2.34 KB
/
graphableLine.java
File metadata and controls
89 lines (81 loc) · 2.34 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* An object that represents a line on a 3D plane. It extends graphable and is represented
* through a start point and an endpoint.
*/
public class graphableLine extends graphable {
//treat x, y, and z as start
private double endX;
private double endY;
private double endZ;
/**
* Common constructor that represents a 3D line
* @param tX The start X coordinate
* @param tY The start Y coordinate
* @param tZ The start Z coordinate
* @param eX The ending X coordinate
* @param eY The ending Y coordinate
* @param eZ The ending Z coordnate
*/
public graphableLine (double tX, double tY, double tZ, double eX, double eY, double eZ){
super(tX, tY, tZ);
endX = eX;
endY = eY;
endZ = eZ;
}
/**
* Secondary constructor when representing a 2D line. Disregards Z axis.
* @param tX The start X coordinate
* @param tY The start Y coordinate
* @param eX The ending X coordinate
* @param eY The ending Y coordinate
*/
public graphableLine (double tX, double tY, double eX, double eY){
super(tX, tY);
endX = eX;
endY = eY;
endZ = 0;
}
/**
* Setter method for the new line
* @param tX The start X coordinate
* @param tY The start Y coordinate
* @param tZ The start Z coordinate
* @param eX The ending X coordinate
* @param eY The ending Y coordinate
* @param eZ The ending Z coordnate
*/
public void setLine (double tX, double tY, double tZ, double eX, double eY, double eZ){
setPoint(tX, tY, tZ);
endX = eX;
endY = eY;
endZ = eZ;
}
/**
* Getter method for the ending X point
* @return The ending X coordinate
*/
public double getEX (){
return endX;
}
/**
* Getter method for the ending Y point
* @return The ending Y coordinate
*/
public double getEY (){
return endY;
}
/**
* Getter method for the ending Z part
* @return The ending Z coordinate
*/
public double getEZ (){
return endZ;
}
/**
* Overrides the toString method
* @return the string in a new format
*/
public String toString() {
return getX() + " " + getY() + " " + getZ() + " TO " + getEX() + " " + getEY() + " " + getEZ();
}
}