Public Group

# polygon morphing

This topic is 4090 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I know this is probably a simple graphing problem, but it's been so long since I've had to use any of this that what I remember from my high school math classes has gotten kinda fuzzy and I'm not really sure where to begin to look for an answer. I've got a table that's basically just a list of x,y coordinates. When I pass this table to my polygon drawing function it goes through the list and draws a line from one point to the next, connecting back to the first point when it reaches the end. What I'd like to do is make a function that can take two of these tables and display an animation of the first polygon morphing into the second. For example, if one table had the first point at x1,y1 and the other had the first point at x2,y2 how could I find the location of the point for the current animation frame based on the max number of frames?

##### Share on other sites
linear interpolation

x1' = x1 + alpha * (x2 - x1)

alpha as to be in the range of [0,1]
normalize your current frame like this: alpha = currentFrame / frameCount

##### Share on other sites
Thanks! My morphing function works perfectly after plugging that formula into it.

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 23
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631766
• Total Posts
3002236
×