drosofff
12/31/2016 - 12:54 AM

## Work on acceleration in plan. Note that work is still needed on "acceleration factor" which is - in acceleration.r - opposite to classical f

Work on acceleration in plan. Note that work is still needed on "acceleration factor" which is - in acceleration.r - opposite to classical force (higher when far)

``````forces <- function(df_coordinates, X, Y, indice){
df_coordinates\$F =1/log(sqrt((df_coordinates\$x-X)^2 + (df_coordinates\$y-Y)^2)^2)
df_coordinates\$ang = atan2(df_coordinates\$y-Y, df_coordinates\$x-X)
df_coordinates\$Di = df_coordinates\$F * cos(df_coordinates\$ang)
df_coordinates\$Dj = df_coordinates\$F * sin(df_coordinates\$ang)
colnames(df_coordinates)[c(length(colnames(df_coordinates))-3,length(colnames(df_coordinates))-2,length(colnames(df_coordinates))-1,length(colnames(df_coordinates)))]=c(paste("F", indice, sep=""),  paste("ang", indice, sep=""), paste("Di", indice, sep=""), paste("Dj", indice, sep=""))
return(df_coordinates)
}
# Then
x = sort(runif(10000, 0, 99))
y = runif(10000, 0, 99)
plan = data.frame(x, y)
plan=forces(plan,10,20,1)
plan=forces(plan,90,80,2)
plot(1, type="n", axes=F, xlab="", ylab="", xlim=c(0,100), ylim=c(0,100))
points(plan\$x, plan\$y, pch=20, cex=0.3, col="red")
segments(plan\$x,plan\$y,plan\$x+((plan\$Di1+plan\$Di2)*100),plan\$y+((plan\$Dj1+plan\$Dj2)*100), col=colors()[abs(atan2(plan\$ang2,plan\$ang1)*cos(plan\$ang1))*150], lwd=4)

# colour variations
# col=colors()[abs(sin(plan\$ang2)*cos(plan\$ang1))*20]
# col=colors()[2^(sin(plan\$ang2)*cos(plan\$ang1))*20]
``````
``````forces <- function(df_coordinates, X, Y, indice){
df_coordinates\$F =cos( sqrt((df_coordinates\$x-X)^2 + (df_coordinates\$y-Y)^2) )
df_coordinates\$ang = atan2(df_coordinates\$y-Y, df_coordinates\$x-X)
df_coordinates\$Di = df_coordinates\$F * cos(df_coordinates\$ang)
df_coordinates\$Dj = df_coordinates\$F * sin(df_coordinates\$ang)
colnames(df_coordinates)[c(length(colnames(df_coordinates))-3,length(colnames(df_coordinates))-2,length(colnames(df_coordinates))-1,length(colnames(df_coordinates)))]=c(paste("F", indice, sep=""),  paste("ang", indice, sep=""), paste("Di", indice, sep=""), paste("Dj", indice, sep=""))
return(df_coordinates)
}
# then
x = sort(runif(10000, 0, 99))
y = runif(10000, 0, 99)
plan = data.frame(x, y)
plan=forces(plan,20,80,1)
plan=forces(plan,80,20,2)
par(mar=c(1,1,0,0), bg="gray15")
plot(1, type="n", axes=F, xlab="", ylab="", xlim=c(0,100), ylim=c(0,100))

segments(plan\$x,plan\$y,plan\$x-(exp(plan\$Di1)/exp(plan\$Di2)),plan\$y-(exp(plan\$Dj1)/exp(plan\$Dj2)), col=rgb(runif(1000),0,0,1), lwd=3)
``````
``````forces <- function(df_coordinates, X, Y, indice){
df_coordinates\$F =cos( sqrt((df_coordinates\$x-X)^2 + (df_coordinates\$y-Y)^2) )
df_coordinates\$ang = atan2(df_coordinates\$y-Y, df_coordinates\$x-X)
df_coordinates\$Di = df_coordinates\$F * cos(df_coordinates\$ang)
df_coordinates\$Dj = df_coordinates\$F * sin(df_coordinates\$ang)
colnames(df_coordinates)[c(length(colnames(df_coordinates))-3,length(colnames(df_coordinates))-2,length(colnames(df_coordinates))-1,length(colnames(df_coordinates)))]=c(paste("F", indice, sep=""),  paste("ang", indice, sep=""), paste("Di", indice, sep=""), paste("Dj", indice, sep=""))
return(df_coordinates)
}
# then
x = sort(runif(10000, 0, 99))
y = runif(10000, 0, 99)
plan = data.frame(x, y)
plan=forces(plan,10,10,1)
plan=forces(plan,90,90,2)
par(mar=c(1,1,0,0), bg="gray15")
plot(1, type="n", axes=F, xlab="", ylab="", xlim=c(0,100), ylim=c(0,100))
points(plan\$x, plan\$y, pch=20, cex=0.3, col="red")
segments(plan\$x,plan\$y,plan\$x-(exp(plan\$Di1)/exp(plan\$Di2)),plan\$y-(exp(plan\$Dj1)/exp(plan\$Dj2)), col="gray98", lwd=3)``````
``````acceleration <- function (X, Y, masse, indice){
x = sort(runif(10000, 0, 99))
y = runif(10000, 0, 99)
plan = data.frame(x, y)
distance = sqrt((plan\$x-X)^2 + (plan\$y-Y)^2)
G = 10
plan\$F = distance^(3/2) /(G * masse)
plan\$ang = atan2(plan\$y-Y, plan\$x-X)
plan\$Di = (1+plan\$F) * cos(plan\$ang) # 1 to view null force
plan\$Dj = (1+plan\$F) * sin(plan\$ang) # to view null force
# following manipulation not required but kept for future developments
colnames(plan)[c(length(colnames(plan))-3,length(colnames(plan))-2,length(colnames(plan))-1,length(colnames(plan)))]=c(paste("F", indice, sep=""),  paste("ang", indice, sep=""), paste("Di", indice, sep=""), paste("Dj", indice, sep=""))
plot(1, type="n", axes=F, xlab="", ylab="", xlim=c(0,100), ylim=c(0,100))
segments(plan\$x,plan\$y,plan\$x+((plan\$Di1)),plan\$y+((plan\$Dj1)), col="darkgreen", lwd=1)
}``````