Collision Detection on SMIL Animation Path
Collision Detection on SMIL Animation Path
I have a thread in JavaScript watching two animated shapes. I would like to detect when they collide but I can't get the current position of the shapes as the animateTransform being processed does not update the shapes' coordinates. How should I go about collision detection with SMIL animates?
-
- Posts: 4
- Joined: Wed Mar 30, 2011 5:36 am
Re: Collision Detection on SMIL Animation Path
When I did this (it was ages ago) I used the fact that one can get the length of a path and the co-ordinates of a point a distance down the path. A quick google search didn't show how to find the latter but if you persevere it is there somewhere.
Good luck!
Good luck!
-
- Posts: 4
- Joined: Wed Mar 30, 2011 5:36 am
Re: Collision Detection on SMIL Animation Path
For locating a point on the path, I'm pretty sure I gave 1 as the length attribute:
http://www.w3.org/TR/SVG/paths.html#DistanceAlongAPath
which is of course bogus but it made everything else easy.
http://www.w3.org/TR/SVG/paths.html#DistanceAlongAPath
which is of course bogus but it made everything else easy.
Re: Collision Detection on SMIL Animation Path
I don't really understand what you mean by this, are you talking about distance along animation paths or a path element? Perhaps an example would make it clear.
As for my own progress on this issue, I've been trying to use the "getBBox()" method of the animated element to obtain its current position in a continuous thread. I haven't had much chance to work on it but when I figure out if that will work I will post the results.
As for my own progress on this issue, I've been trying to use the "getBBox()" method of the animated element to obtain its current position in a continuous thread. I haven't had much chance to work on it but when I figure out if that will work I will post the results.
Re: Collision Detection on SMIL Animation Path
I have (somewhat) solved this issue using the getBBox() method. Although I have not done collision detection, I have successfully found the coordinates of an animated element using getBBox() and getCTM(). Working example follows:
http://static.dorshnik.com/test/point-on-path.svg
http://static.dorshnik.com/test/point-on-path.svg