• Tortion spring and damper aka angular elastic tool
    10 replies, posted
[URL]http://en.wikipedia.org/wiki/Torsion_spring[/URL] Yeah, this would be really cool, we would be able to make wind up cars n clockwork stuff. also the damper would be good for car breaks. It could just be the same as the axis tool, except exert a torque proportional to the angle of twist (spring) and proportional to the angular velocity (damper). Wiremod demo video of how it would work; [media]http://www.youtube.com/watch?v=LD3GFASCocQ[/media] Basicaly, Torque = angular displacement * spring constant - angular velocity * damping constant, where angles are in radians. e2 code; [CODE]@name tortion spring @inputs Target:entity K C @outputs Yawv Iyaw Yaw Correctedyaw Turncount Tyaw @persist @trigger none runOnTick(1) # turning the yaw from -180 to 180 into 0 to 360; if (sign(Target:angles():yaw()) == 1) {Yaw = Target:angles():yaw()} else {Yaw = 360 + Target:angles():yaw()} # calculating corrected yaw, the yaw from the initial start point; if (first()) {Iyaw = Yaw} if (Yaw > Iyaw) {Correctedyaw = Yaw - Iyaw} else {Correctedyaw = 360 - Iyaw + Yaw} # calulating total yaw, using a counter; Yawv = toRad(Target:angVel():yaw()) if (sign(Yawv) == -1 & $Correctedyaw > 180) {Turncount--} if (sign(Yawv) == 1 & $Correctedyaw < -180) {Turncount++} #making sure Tyaw always starts at 0 if (first() & Correctedyaw == 360) {Turncount = -1} Tyaw = toRad(Turncount * 360 + Correctedyaw) # T = -k * theta -c * omega Target:applyTorque(vec(0, 0, -K * Tyaw - C * Yawv) / 66.566669) [/CODE] Yeah, its torsion, not tortion - I'm retarded :redface:
This may already be possible with Wiremod - for each turn of a wheel you could add 1 to a counter, and then when it stops turning, turn it the other way until the counter hits 0 again.
I realise that. I could quite easily make it with applyTorque and a counter like you say. What I'm asking for is a vanilla gmod tool for it, this would benefit everyone, rather than the minority who properly understand wiremod.
Oh yes, a vanilla tool would be very useful. Since you understand the base concept, why don't you try putting together a little one of your own? I shouldn't think it'd take more than a few lines of Lua to get this up and running. Not to mention, it'd cut out work for Garry since he could implement your tool.
Mmm, coding lua, that's the problem. I don't even know where to find the axis tool lua which I would use as a starting point.
See, the thing is the current constraint tools create constraints that the Source engine supports. Source doesn't have coilsprings.
Well it can definitely be done in wiremod with applyTorque so it should be equally feasible in lua for vanilla gmod.
Updated OP with wiremod demonstration of the concept.
O wait, are you looking for a spring entity or for a constraining tool (read WM thread)?
Well torsion springs work around an axis so it would have to be an axis tool, but with a spring stiffness and damping slider on it. Me and divran are working on a lua version at the moment.
Bump
Sorry, you need to Log In to post a reply to this thread.