Add some symmetry to edge point calculation function
This commit is contained in:
parent
e6cc5d687e
commit
7d9073eebf
14
index.js
14
index.js
@ -30,21 +30,19 @@ function edgePoint(x1, y1, x2, y2, maxX, maxY) {
|
|||||||
let yWhenXisMax = yIntercept(maxX);
|
let yWhenXisMax = yIntercept(maxX);
|
||||||
let xWhenYisZero = xIntercept(0);
|
let xWhenYisZero = xIntercept(0);
|
||||||
|
|
||||||
if (xWhenYisZero <= maxX) {
|
if (yWhenXisMax >= 0) {
|
||||||
// yWhenXisMax
|
|
||||||
pointCoords = [xWhenYisZero, 0];
|
|
||||||
} else {
|
|
||||||
pointCoords = [maxX, yWhenXisMax];
|
pointCoords = [maxX, yWhenXisMax];
|
||||||
|
} else {
|
||||||
|
pointCoords = [xWhenYisZero, 0];
|
||||||
}
|
}
|
||||||
} else if (xDiff < 0 && yDiff < 0) {
|
} else if (xDiff < 0 && yDiff < 0) {
|
||||||
let yWhenXisZero = yIntercept(0);
|
let yWhenXisZero = yIntercept(0);
|
||||||
let xWhenYisZero = xIntercept(0);
|
let xWhenYisZero = xIntercept(0);
|
||||||
|
|
||||||
if (yWhenXisZero >= 0) {
|
if (xWhenYisZero >= 0) {
|
||||||
// xWhenYisZero
|
|
||||||
pointCoords = [0, yWhenXisZero];
|
|
||||||
} else {
|
|
||||||
pointCoords = [xWhenYisZero, 0];
|
pointCoords = [xWhenYisZero, 0];
|
||||||
|
} else {
|
||||||
|
pointCoords = [0, yWhenXisZero];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let yWhenXisZero = yIntercept(0);
|
let yWhenXisZero = yIntercept(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user