Hi,
I am interested in being able to calculate the distance a particle travels as an exercise in attrib vop from a source pop . I thought this would be possible first by taking @v and calculating the length of the vector to give me the speed of the point. THen f@speed * f@timeinc = distance traveled but my distance values are tiny even though I can see over 1 meter has been covered.
Can anyone give me a pointer, I feel as if I must be missing something really simple.
Rob
Q: calculate particle distance attrib vop
5568 8 2- circusmonkey
- Member
- 2624 posts
- Joined: 8月 2006
- Offline
- Doodlez
- Member
- 25 posts
- Joined: 10月 2012
- Offline
Using f@speed * f@timeinc = distance gives you the distance traveled over a single frame, your f@timeinc increment.
If you want the total distance you need to use your total timespan*speed.
If your velocity changes in between frames you could still use f@speed * f@timeinc = distance and keep adding that value to a total distance value.
If you want the total distance you need to use your total timespan*speed.
If your velocity changes in between frames you could still use f@speed * f@timeinc = distance and keep adding that value to a total distance value.
- jlait
- スタッフ
- 6427 posts
- Joined: 7月 2005
- Offline
- circusmonkey
- Member
- 2624 posts
- Joined: 8月 2006
- Offline
- tjeeds
- Member
- 339 posts
- Joined: 8月 2007
- Offline
- circusmonkey
- Member
- 2624 posts
- Joined: 8月 2006
- Offline
- jlait
- スタッフ
- 6427 posts
- Joined: 7月 2005
- Offline
Use a build of 14.0.227 or later.
Then in your popwrangel type:
f@totaltimespan = ch(“total_time”);
Then hit the little button that looks like a plug to the right of the multiline editor.
A parameter called Total Time will now be made, which that ch will refer to. In that parameter you can do your $NFRAME/$FPS.
You can also type
f@totaltimespan = $NFRAME/$FPS;
and it will work since we do global variable replacement in VEX strings. But I do not recommend that.
Then in your popwrangel type:
f@totaltimespan = ch(“total_time”);
Then hit the little button that looks like a plug to the right of the multiline editor.
A parameter called Total Time will now be made, which that ch will refer to. In that parameter you can do your $NFRAME/$FPS.
You can also type
f@totaltimespan = $NFRAME/$FPS;
and it will work since we do global variable replacement in VEX strings. But I do not recommend that.
- circusmonkey
- Member
- 2624 posts
- Joined: 8月 2006
- Offline
Thanks !
// @TimeInc is a global variable
// @speed * @TimeInc = total distance travelled over 1 frame
f@speed = length(@v);
f@distperframe = f@speed * @TimeInc;
f@totaltimespan = ch("total_time");
f@totaldist = @totaltimespan*@speed;
//
f@test = @totaldist + @distperframe;/code]
Something is wrong with the initial solution. Jeff your solution works and gives me the correct numbers in the spreadsheet. but I can no reference to pprevious in the houdini help.
Rob
Gone fishing
- jlait
- スタッフ
- 6427 posts
- Joined: 7月 2005
- Offline
pprevious should be documented in the particle attribute list
http://www.sidefx.com/docs/houdini14.0/dopparticles/attributes [sidefx.com]
I'm a bit confused why your code is using f@tottaltimespan for this. It is causing it to be set to the total distance if the particle travelled at the current speed for all time. Usually you want to just integrate it, so I'd suggest
f@speed = length(@v); // dist per second
f@distperframe = @speed * @TimeInc; // Dist in this substep
f@totaldist += @distperframe; // Integrate
This may not give the same result as velocity does not always equal the movement over the frame. (An obvious example is a particle that bounces)
Another subtle point is that your distperframe isn't quite distance per frame. If you turn on substepping at the DOP or POP level it will be much smaller as it will just be the distance in this substep.
http://www.sidefx.com/docs/houdini14.0/dopparticles/attributes [sidefx.com]
I'm a bit confused why your code is using f@tottaltimespan for this. It is causing it to be set to the total distance if the particle travelled at the current speed for all time. Usually you want to just integrate it, so I'd suggest
f@speed = length(@v); // dist per second
f@distperframe = @speed * @TimeInc; // Dist in this substep
f@totaldist += @distperframe; // Integrate
This may not give the same result as velocity does not always equal the movement over the frame. (An obvious example is a particle that bounces)
Another subtle point is that your distperframe isn't quite distance per frame. If you turn on substepping at the DOP or POP level it will be much smaller as it will just be the distance in this substep.
-
- Quick Links