I'm trying to write a function to switch negative to positive and vise-versa. I've got:
foot=3 function switch(f) f*=-1 end |
when I call switch(foot) it returns the original value but if at the command prompt I type "foot*=-1 it preforms as expected.
Thanks for any help and sorry for these remedial questions.
--
-john
I would like to create a function that would move one point in along a circle around another, but lack the math know how.
here's what I have cobbled together from examples elsewhere and a little help, hopefully at least my intentions are clear (the inc=increment would let me fiddle with how fast p2 travels)
point1={}
point1.x=68
point1.y=78
point2={}
point2.x=57
point2.y=43
function orbit(p1, p2, inc)
distance = sqrt((p1.x-p2.x)(p1.x-p2.x) + (p1.y-p2.y)(p1.y-p2.y))
ang= atan2(p2.y, p2.x) - atan2(p1.y, p2.x)
p2.x=(p1.x + distance cos(ang+inc))
p2.y=(p1.y + distance sin(ang+inc))
end
function _update()
orbit(point1, point2, .01)
end
function _draw()
line(point1.x, point1.y, point2.x, point2.y, 7)
end
--
-john