Here are are some functions I made that make an object follow a few types of curves, like sine curves, artangent curves, and even a circle as a parametric curve.
I think I would have to do some type of parametric curve fitting.
--Outside the onSceneUpdate() function
u=0
ground = 2
center = vec3{0,0,ground}
x = u
y = 0
drag = 5
--These functions called inside the onSceneUpdate() function
function Sinuside(object)
u = u + 1
x = u/drag
y = 9*math.sin(x)
path = vec3(x,y,ground)
setPosition(object,path)
end
function Cosinide(object)
u = u + 1
x = u/drag
y = 9*math.cos(x)
path = vec3(x,y,ground)
setPosition(object,path)
end
function Arctangic(object)
u = u + 1
x = u/drag
y = 9*math.atan(x)
path = vec3(x,y,ground)
setPosition(object,path)
end
function ArcSinusidal(object)
u = u + 1
x = u/drag
y = math.asin(x/60)
path = vec3(x,y,ground)
setPosition(object,path)
end
--x = r cos(t) y = r sin(t)
function Circulate(object,radius,speed)
u = u + speed
x = speed * radius * math.cos(u)
y = speed * radius * math.sin(u)
path = vec3(x,y,ground)
setPosition(object,path)
end
function Elipticate(object,width,height)
u = u + .1
x = width * math.cos(u)
y = height * math.sin(u)
path = vec3(x,y,ground)
setPosition(object,path)
end
Last edited by Tutorial Doctor (2014-04-28 20:12:56)