-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathTestLines.java
More file actions
87 lines (58 loc) · 2.43 KB
/
TestLines.java
File metadata and controls
87 lines (58 loc) · 2.43 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
// TestLines.java
// a simple java file for console program
// Imports
import net.javageom.geom2d.*;
import net.javageom.geom2d.line.StraightLine2D;
/**
* class TestLines.
*/
public class TestLines{
// ===================================================================
// main method
public final static void main(String arg[]){
double theta;
Point2D p1 = new Point2D(-1, 0);
Point2D p2 = new Point2D(1, 0);
StraightLine2D line1 = new StraightLine2D(p1, p2);
theta = line1.horizontalAngle();
System.out.println("angle : " + theta);
Point2D p3 = new Point2D(0, -1);
Point2D p4 = new Point2D(0, 1);
StraightLine2D line2 = new StraightLine2D(p3, p4);
theta = line2.horizontalAngle();
System.out.println("angle : " + theta);
Point2D p0 = line1.intersection(line2);
System.out.println("point intersection : " + p0.x() + " " + p0.y());
System.out.println(line1.contains(0, 0));
System.out.println(line1.contains(0, 1e-14));
p1 = new Point2D(-1, 0);
p2 = new Point2D(0, 1);
line1 = new StraightLine2D(p1, p2);
theta = line1.horizontalAngle();
System.out.println("angle : " + theta);
p3 = new Point2D(5, 0);
p4 = new Point2D(4, 1);
line2 = new StraightLine2D(p3, p4);
theta = line2.horizontalAngle();
System.out.println("angle : " + theta);
p0 = line1.intersection(line2);
System.out.println("point intersection : " + p0.x() + " " + p0.y());
line1 = StraightLine2D.createCartesian(-1, 1, 0);
System.out.println("angle (abc) : " + line1.horizontalAngle());
line1 = StraightLine2D.createCartesian(-1, 2, 0);
System.out.println("angle (abc) : " + line1.horizontalAngle());
line1 = StraightLine2D.createCartesian(-1, 1, -1);
System.out.println("angle (abc) : " + line1.horizontalAngle());
line1 = StraightLine2D.createCartesian(-1, 2, -2);
System.out.println("angle (abc) : " + line1.horizontalAngle());
System.out.println("distances --------");
p1 = new Point2D(0, 0);
p2 = new Point2D(1, 1);
line1 = new StraightLine2D(p1, p2);
System.out.println("point (0,0) :" + line1.signedDistance(0,0));
System.out.println("point (1,0) :" + line1.signedDistance(1,0));
System.out.println("point (4,0) :" + line1.signedDistance(4, 0));
System.out.println("point (0,4) :" + line1.signedDistance(0, 4));
System.out.println("point (10, 0) :" + line1.signedDistance(10, 0));
}
}