DarianFlorianVoda / BioShapes

Bachelor Thesis R Package
0 stars 0 forks source link

[Tests] Simple ArrowHead: Mixed #56

Closed discoleo closed 2 years ago

discoleo commented 2 years ago

Simple ArrowHead: Mixed

##### Simple ArrowHead: Mixed ####
# - comparison between different dV (d.head argument);

### Test 1
x = c(0, 6); y = c(1, 6);
d = -1; d2 = -1.5;
plot.base()
a1 = arrowSimple(x, y, d=d, lwd=2);
a2 = arrowSimple(c(x[1], 5), c(y[1], y[1]), d=d, lwd=2);
a3 = arrowSimple(c(x[1], x[1]), c(y[1], 5), d=d, lwd=2);
# different dV:
a4 = arrowSimple(x, y+2, d=d2, d.head=c(-0.5, 0.5), lwd=2);
# Head
h1 = a1$Head[[1]]
h2 = a2$Head[[1]]
h3 = a3$Head[[1]]
h4 = a4$Head[[1]]
# - visual aids:
lines(h1$x[c(1,3)], h1$y[c(1,3)], col="green")
lines(h2$x[c(1,3)], h2$y[c(1,3)], col="green")
lines(h3$x[c(1,3)], h3$y[c(1,3)], col="green")
lines(h4$x[c(1,3)], h4$y[c(1,3)], col="green")
# Total length = (d^2 + dV[1]^2) + (d^2 + dV[2]^2)
stopifnot(round(Dsquare(h1, h1$x[2], h1$y[2]) - 2*d^2 - 2*d^2, 8) == 0)
stopifnot(round(Dsquare(h2, h2$x[2], h2$y[2]) - 2*d^2 - 2*d^2, 8) == 0)
stopifnot(round(Dsquare(h3, h3$x[2], h3$y[2]) - 2*d^2 - 2*d^2, 8) == 0)
stopifnot(round(Dsquare(h4, h4$x[2], h4$y[2]) - 2*d2^2 - 2*(0.5)^2, 8) == 0)
DarianFlorianVoda commented 2 years ago

Added. :)