• Interpolation Module - Beta testing
    41 replies, posted
[highlight]This is a developer release.[/highlight] [img]http://screensnapr.com/u/63j89y.png[/img] I made a simple GUI to test out the module. I'm sure it's going to have lots of bugs, so help me test it! [b]Interpolation module[/b] (goes in /lua/includes/modules/): [url=http://solidfiles.com/d/ZMqk][img]http://solidfiles.com/info_imgs/ZMqk.jpg[/img][/url] [b]Interpolation Graph Test[/b] (goes in /lua/ and needs the above file): [url=http://solidfiles.com/d/fre1][img]http://solidfiles.com/info_imgs/fre1.jpg[/img][/url] Documentation coming later, I'm going to bed! Have fun! [b]Edit:[/b] [code] Stoned: 6666! D: [/code] lol
Thanks.
Looks pretty awesome. Nice work. So if I'm looking at the code right, you have linear, cosine, cubic, and hermite interpolation, right?
Sexy, I gotta apply that somewhere.
Only a question? how could you use that? I mean what is its use?
Looks kewl.
[QUOTE=commander204;17161657]Only a question? how could you use that? I mean what is its use?[/QUOTE] There are many different applications. Making curved paths and beams mostly. The physgun beam uses a form of interpolation - when you sway a prop with it, the beam bends smoothly instead of pointing straight to the prop.
[QUOTE=commander204;17161657]Only a question? how could you use that? I mean what is its use?[/QUOTE] Or with the graph test Deco made, you could make some thing like most Server hosters have where you can see how many players are in the server at times of the day. With lua you could have it far more advanced like how many props, sents, npcs, etc etc not only entities, but do one of player deaths as well during a set period of 24 hours or what ever.
[QUOTE=JSharpe;17162180]Or with the graph test Deco made, you could make some thing like most Server hosters have where you can see how many players are in the server at times of the day. With lua you could have it far more advanced like how many props, sents, npcs, etc etc not only entities, but do one of player deaths as well during a set period of 24 hours or what ever.[/QUOTE] Now that is a brilliant idea!
Might sound dumb but why make a module for it?
It's a lua module, not a binary module.
[QUOTE=JSharpe;17162180]Or with the graph test Deco made, you could make some thing like most Server hosters have where you can see how many players are in the server at times of the day. With lua you could have it far more advanced like how many props, sents, npcs, etc etc not only entities, but do one of player deaths as well during a set period of 24 hours or what ever.[/QUOTE] I know what I'm doing today. :3
[QUOTE=Unrealomega;17162801]I know what I'm doing today. :3[/QUOTE] /me is already in the process.
[QUOTE=JSharpe;17163124]/me is already in the process.[/QUOTE] Mmk. :P
It would be nice to be able to draw the vgui without any points to begin with. Then be able to add them our selfs manually with GraphPanel.PointsTable[x] = y I can't seem to remove any of the points without causing a mass spew of errors.
This just made my Tesla Cannon cooler.
[QUOTE=JSharpe;17162180]Or with the graph test Deco made, you could make some thing like most Server hosters have where you can see how many players are in the server at times of the day. With lua you could have it far more advanced like how many props, sents, npcs, etc etc not only entities, but do one of player deaths as well during a set period of 24 hours or what ever.[/QUOTE] Except that'd be in the vector library on a website, not ingame so we can all rape our CPUs
[QUOTE=LauIsFun;17171114]Except that'd be in the vector library on a website, not ingame so we can all rape our CPUs[/QUOTE] If you set the cache argument to true when creating an interpolating table with interpolation.create then it will only calculate the values once. Or, more if the data changes. I think the cache functionality is broken, though. Gonna have to fix that. Thanks for the good replies, guys :D Anyone found any bugs yet? I'll be adding documentation and implementing more features over the next week or so, then I'll probably loose interest and release it. Recommend some functionality please :D I'm gonna see how animation suites like Flash and vector graphics creators like Illustrator do that angle handle thingy. This could be used for GMod animation suites. You'd be able to control various characteristics of the entities using graphs. The possibilities are endless. You could overlay graphs onto each other. e.g: Red, Green, Blue. I hope I don't loose interest in this :D
[QUOTE=Yobdren;17164017]This just made my Tesla Cannon cooler.[/QUOTE] Yes it did.
[QUOTE=Deco Da Man;17174788]If you set the cache argument to true when creating an interpolating table with interpolation.create then it will only calculate the values once. Or, more if the data changes. I think the cache functionality is broken, though. Gonna have to fix that. Thanks for the good replies, guys :D Anyone found any bugs yet? I'll be adding documentation and implementing more features over the next week or so, then I'll probably loose interest and release it. Recommend some functionality please :D I'm gonna see how animation suites like Flash and vector graphics creators like Illustrator do that angle handle thingy. This could be used for GMod animation suites. You'd be able to control various characteristics of the entities using graphs. The possibilities are endless. You could overlay graphs onto each other. e.g: Red, Green, Blue. I hope I don't loose interest in this :D[/QUOTE] I have a bezier interpolation function (since the one built into GMod doesn't work), perhaps you could include that? [code] function PointOn3DBezierCurve(dis,pt1,pt2,pt3) --my poor attempt at a bezier curve algorthm. I think dis is distance along the curve, pt1 is start, pt2 is control, and pt3 is end. local out1 = ((1-dis)^2)*pt1.x+2*(1-dis)*dis*pt2.x+(dis^2)*pt3.x local out2 = ((1-dis)^2)*pt1.y+2*(1-dis)*dis*pt2.y+(dis^2)*pt3.y local out3 = ((1-dis)^2)*pt1.z+2*(1-dis)*dis*pt2.z+(dis^2)*pt3.z return Vector(out1,out2,out3) end [/code] and if you only want interpolation for 1 dimension: [code] function BezierInterpolation(dis,pt1,pt2,pt3) --my poor attempt at a bezier curve algorthm. I think dis is distance along the curve, pt1 is start, pt2 is control, and pt3 is end. return ((1-dis)^2)*pt1+2*(1-dis)*dis*pt2+(dis^2)*pt3 end [/code] [editline]11:29AM[/editline] It's a quadratic bezier curve algorithm to be precise. [editline]11:31AM[/editline] I could make a cubic bezier function quite easily... [editline]11:47AM[/editline] [code] function CubicBezierInterpolation(dis,pt1,pt2,pt3,pt4) return ((1-dis)^3)*pt1+3*((1-dis)^2)*dis*pt2+3*((1-dis)^2)*dis*pt3+(dis^3)*pt4 end [/code] There we go. Should work for cubic bezier interpolation, haven't tested it, though. As you can see, quadratic only has 1 control point for the curve, and cubic has 2. I could *try* to make the generalization function (so you can have bezier curves of the nth degree), but I'm not quite sure how well that will go...
Oh... so this isnt only 2D? Well then! That is awesome! As you can make Things move smothly etc right?
Question: why not use math.EaseInOut( progress, 0.5, 0.5 )? It appears to be the same, and it's pretty damn smooth (I tested it for smoothly changing the camera origin + angles in CalcView, looked pretty damn awesome)
-snip-
[QUOTE=CptFuzzies;17197811]:wtf: Someone made a module that's actually useful and CAN'T be replicated in Lua?[/QUOTE] This is made in Lua.
Time for GMod virtual stock tracking... I'm actually thinking about some of the cool things you can make with this :) Thanks Deco.
-snip-
[QUOTE=Levybreak;17177181]awesomeness[/QUOTE] Woah, thanks for that Levybreak. I'll be sure to put it in (if you allow me, of course). [QUOTE=commander204;17179972]Oh... so this isnt only 2D? Well then! That is awesome! As you can make Things move smothly etc right?[/QUOTE] The interpolation functions are [b][i]one[/i][/b] dimensional. You can use them three times to get 3D. [QUOTE=Dlaor;17180436]Question: why not use math.EaseInOut( progress, 0.5, 0.5 )? It appears to be the same, and it's pretty damn smooth (I tested it for smoothly changing the camera origin + angles in CalcView, looked pretty damn awesome)[/QUOTE] If you're talking about interpolation in general: EaseInOut only accepts two points, meaning it has no continuity between multiple points. Cubic and Hermite (and Bezier) take 4 points and use the first and last to modify the curve between the middle two so that the lines smoothly join at the points. As for interpolation.ease: I have OCD and I hate the way Garry codes, I just had to remake it. It essentially does the same thing. [QUOTE=CptFuzzies;17197811]stupid words[/QUOTE] You're an idiot. [QUOTE=Roiyaru;17204542]Time for GMod virtual stock tracking... I'm actually thinking about some of the cool things you can make with this :) Thanks Deco.[/QUOTE] math.EaseInOut (or interpolation.ease) is enough for those sorts of graphs, as you are constantly recording the data and don't need to 'smooth' it. You often don't want to smooth it, especially with functions such as cubic or hermite (or bezier), as they may over shoot the correct value to remain smooth. God damned school is taking all my time. If you feel like adding anything to this, please do.
[QUOTE=Deco Da Man;17208478]Woah, thanks for that Levybreak. I'll be sure to put it in (if you allow me, of course). [/QUOTE] Of course you can add it in, just give credit. :D I'll also go work on the nth degree bezier curve function, so you can have as many control points as you'd like... (All controling the same curve, too!) [editline]04:48PM[/editline] [code] function Factorial(n) if n == 0 then return 1 else return n * factorial(n - 1) end end function Combinations(n,k) return factorial(n)/(factorial(k)*factorial(n-k)) end function BezierGeneralization(dis,...) local pts = {...} local n = #pts local ret = 0 --((1-dis)^n)*pts[1] for i=1,n do ret = ret+(Combinations(n,i)*((1-dis)^(n-i))*(dis^i)*pos[i]) end return ret --+((dis^n)*pts[n]) end [/code] Should work. Completely untested, ofc. With only 2 points you'll just get a more math-intensive linear interpolation, with more you get bezier inperpolation to the nth degree. Thank wikipedia (and this picture: [img]http://upload.wikimedia.org/math/e/e/5/ee540a45155c347d28adddfcb0486b42.png[/img]), and me finally figuring out what the hell a binomial coefficient is, especially since I've never touched complex numbers before in my life. (Just started algebra 2 today.) I imagine you'll still want to keep the basic cubic and quadratic interpolation as well, since they are less computationally expensive since the factorials and combinations and such are already solved.
Oh hey guys what's u- [QUOTE=Levybreak;17214918][img]http://upload.wikimedia.org/math/e/e/5/ee540a45155c347d28adddfcb0486b42.png[/img][/QUOTE] :suicide:
This will be great for curved movement paths. I wanna see some curving bullets!
Sorry, you need to Log In to post a reply to this thread.