[Closed] [MATH][WIP] accelaration along path
Hello,
I want to animate a “car” along a path using a path constraint.
So far so good.
I want to be able to specify the speed of the car using realworld scales:
t0 = 50km/h
t1 = 50km/h
t2 = 75km/h
with tn being some point in time.
I tried multiplier and ease curves and they worked as exspected but not the way I want.
Idea:
Custom Attribute for speed
Expression Controller / Wire Parameter to calculate the Percent along Path based on speed:
accelertion: a = (v2 -v1)/t
distance: s = 1/2 a * t^2 + v1*t
Is this a good idea?
Con: It is not “history independent” and may become slow.
Con: specifying speed/time is not desired. speed/position is what I want.
Is there a “easier” way to do this?
Georg
it seems that we are solving the same problems.
i have wrote a script for this task. but it is key based (no controllers)
you could do it with a scripted controller.
i would do something like
you could point the varibles to spinners this way you can controll the hole thing live.
p.s
i haven’t tried this so it might be all wrong.
ogSplLenght = curveLenght $'yourSpline' --this figures out how long the path is
startFrame = 1 --this just lets you set at what frame to start on the path
Speed = 10 -- lets say this is 10 miles an hour
/*
now we need to figure out how does the speed brake down to per frame basis.
for this we will divide speed by the number of frames in an hour base on 30fps shoot.
the number of frames in an hour i thinking is 30(frames in a second) times 60 (seconds in a minute)
times 60 (minutes in an hour).
*/
--distance per frame
DisPerFrm = speed/(60. * 60. * 30.)
--get the traveled distance so far
travDis = DisPerFrm * (currenttime - startFrame)
--get the percange that the traveled distance is compared to the Spline
percnt = travDis/ogSplLenght -- the proper percantage
thank you 111,
i will have a look at your script.
After a lot of meditation a figured out that my first approach was callow.
I didn’t recognise first that I cant set time, position and velocity together …
As time, position and velocity influence eachother it may be better to simulate this.
Anyway I want to develop this interface for this task and if I can base it on your script it will be much easier … depending on your script does what I need …
In the viewport I want markers to show me the speedchanges:
This rollout could be attached to the little car icon or be just a floater like yours:
[left]Maybe there could be a activeX Listview, too.
The script should also:
adjust the timeframe of the animation
expose the velocity and acceleration at current time
Georg
[/left]
111, CarlosA,
maybe I am really thinking too complicated …
but I was sure to take account of acceleration there needs to be some integral-like thing in it.
I will try to understand your scripts.
Georg
there was a problem here with the aceleration you are right…
i did a simple scene to test it, and it seems to only work with a initial speed, and not when i animate the speed.
seem like a simple thing to fix.
i just need to cash the amount travealed and ad increments per frame.
i will brew up a little scene and post it up.
ok came up with this one.
it’s a little bit more like a sim sence it caches the the distanced travealed and builds from there on.
the issue with this one is that it looks funky when you step through it backwards(sence it still builds up based on frame range.)
you could fix this by caching the amount of frames calculated to an attribute and compareing the current frame if the sum is = less the the amounts cashed you subtract the distance increment from the cache instead of adding it.
by the way in the scene i’m using spinners to cache
but if you look into custom attributes you can create controllers that are not visible to the interface. this would clean up alot.
oh yeah i also put a case of to clamp the values
either way maybe this is getting to complicated maybe backing it out would be the esier way
i only like the controller idea becuse you can tweak it imidiatly but you would probably still want to scrub from the beiging for it to work.
DependsOn $Line01 $point01
sF = $Point01.Attribute_Holder.Custom_Attributes.startFrame
t = currentTime
p = 0
travDis = 0
if t >= sF then
(
disCache = $Point01.modifiers[#Attribute_Holder].Custom_Attributes.Cache
splLgth = curvelength $Line01
Speed = $Point01.Attribute_Holder.Custom_Attributes.SpeedMaxUnits_h
DisPerFrm = speed/(60. * 60. * 30.)
travDis = disCache + DisPerFrm
p = (travDis/splLgth) * 100
/*
case of
(
(p > 100.0):p = 100
(p < 0.0):p = 0
default:p
)
*/
)
$Point01.modifiers[#Attribute_Holder].Custom_Attributes.Cache = travDis
p
i do not like scripted controllers, as once, i had to enlarge a time range in my scene. and for the newly added time my scripted controllers didn’t work. keys seems to me as more standard, reliable and flexible approach.
i can understand that but there is a simple fix for that problem.
that problem is cused becuse the range of wire reactor script expresion and may be a few otehr controllers is automaticaly set to the current animation range when they are made.
i have a script on my web sight that will change the range of all this types of controllers to work from something like -1000000 to 1000000 which i think usualy covers all the basis.
the script allows you to change does numbers in case you need a bigger range.
scripted controllers are super usefull and power full, you would miss out on alot of power by ignoring them, in the other hand i don’t think there is anything wrong with the keyframed aprouch, in the end it gives you the same result plus it might help you visualy the whole thing better.
http://losart3d.com/scripts/LosRenger.zip
it didn’t take me that long to come up with my method, but i haven’t tested it.
i wouldn’t be surprised if it dosn’t really work the way i expect it to, and it got a little more complicated that i like it too.
so i think as anybody else the ideas are fast but working them out in debuging them might take some time.
cheers,
Los.
thank you for your input.
I think I will first go the simulation route.
The target application is – guess what – the visualisation of a new highway and it is about 11km long. so the interactive mode will be very inactive I guess due to his history dependance.
–
I always wonder how fast you guys are – I didn’t even break the problem down to its core and you come up with a solution …
111, do you remember how long it took you to get your script working?
Carlos it took you ~15min ?
I sometimes need several days to get stuff working … am I too slow?
Have a good weekend.
Georg
i wrote my script in january and it took me definetely not 15 minutes. a couple of days.