Displaying 1 result from an estimated 1 matches for "invecx".
Did you mean:
invec1
2008 Oct 20
2
R Newbie Question
...ar2center[1] = 0.5
star2center[2] = 0
star2mass = 1
sqr = function(x) {
return(x * x)
}
distance = function(a, b) {
return(sqrt(sqr(a[1] - b[1]) + sqr(a[2] - b[2])))
}
len = function(x) {
return(sqrt(sqr(x[1]) + sqr(x[2])))
}
norm = function(x) {
return(x / len(x))
}
gravitation = function(invecx, invecy) {
invec = vector("numeric", 2)
invec[1] = invecx
invec[2] = invecy
vec1 = star1mass * norm(star1center - invec) / sqr(distance(invec,
star1center))
vec2 = star2mass * norm(star2center - invec) / sqr(distance(invec,
star2center))
return(len(vec1 + vec2))
}
vmin = -1
vmax =...