Closed discoleo closed 2 years ago
Add the actual test:
#### Tests #### Dsquare = function(xy, x0, y0) { sum((xy$x - x0)^2, (xy$y - y0)^2) }
The Visual & Actual Tests:
#### Diagonal, H & V Tests #### ##### Simple ArrowHead #### ### Test 1 x = c(0, 6); y = c(1, 6); d = -1; plot.base() a1 = arrowSimpleH(x, y, d=d, lwd=2); a2 = arrowSimpleH(c(x[1], 5), c(y[1], y[1]), d=d, lwd=2); a3 = arrowSimpleH(c(x[1], x[1]), c(y[1], 5), d=d, lwd=2); # Head h1 = a1$Head[[1]] # - visual aids: lines(h1$x[c(1,3)], h1$y[c(1,3)], col="green") stopifnot(round(Dsquare(h1, h1$x[2], h1$y[2]) - 2*d^2 - 2*d^2, 8) == 0) # TODO: a2, a3; ### Test 2 plot.base() x = c(0, 6); y = c(1, 6) + 1; d=-1.5; d.head = c(-0.5, 0.5); a1 = arrowSimpleH(x, y, d=d, d.head=d.head, lwd=2); a2 = arrowSimpleH(c(x[1], 5), c(y[1], y[1]), d=d, d.head=d.head, lwd=2); a3 = arrowSimpleH(c(x[1], x[1]), c(y[1], 5), d=d, d.head=d.head, lwd=2); # Head h1 = a1$Head[[1]] # - visual aids: lines(h1$x[c(1,3)], h1$y[c(1,3)], col="green") stopifnot(round(Dsquare(h1, h1$x[2], h1$y[2]) - 2*d^2 - sum(d.head^2), 8) == 0) # TODO: a2, a3;
Added.
Arrow.Tests
Add the actual test:
Helper Test Function
The Visual & Actual Tests: