MCPcopy Index your code
hub / github.com/careercup/ctci / Line

Method Line

java/Chapter 7/Question7_6/Line.java:10–18  ·  view source on GitHub ↗
(GraphPoint p, GraphPoint q)

Source from the content-addressed store, hash-verified

8 private boolean infinite_slope = false;
9
10 public Line(GraphPoint p, GraphPoint q) {
11 if (Math.abs(p.x - q.x) > epsilon) { // if x�s are different
12 slope = (p.y - q.y) / (p.x - q.x); // compute slope
13 intercept = p.y - slope * p.x; // y intercept from y=mx+b
14 } else {
15 infinite_slope = true;
16 intercept = p.x; // x-intercept, since slope is infinite
17 }
18 }
19
20 public boolean isEquivalent(double a, double b) {
21 return (Math.abs(a - b) < epsilon);

Callers

nothing calls this directly

Calls 1

absMethod · 0.80

Tested by

no test coverage detected