# Clicca e vedi che succede. Quindi clicca nuovamente.
# Quando vuoi smettere premi il tasto ESC
par( mai = c(0.5,0.5,0.1,0.1) )
f <- function(x) (x-xA)^2+yA
a <- -5; b <- 5; c <- -5; d <- 5
while(1==1) {
xA <- 0; yA <- 0
plot(c(a,b),c(c,d),type="n",xlab="", ylab="")
abline(h=0,v=0,col="red")
abline(h=seq(-5,5,1),v=seq(-5,5,1),lty=3,col="grey")
plot(f,a,b,add=TRUE)
text(1,4.5,"y = x^2")
p <- locator(1)
text(1,4.5,"y = x^2",col="white")
xA <- round(p$x*10)/10; yA <- round(p$y*10)/10
plot(f,a,b,add=TRUE,col="blue")
text(0,-4.5,paste("x^2 + (",-2*xA,")x + (",yA+xA^2,")",sep=""))
text(xA,-0.5,xA); text(0.5,yA,yA)
locator(1)
}
#