Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2009-01-11 22:29:41

Raoul
Guest

geometry vertex position calculation flag

Hi,

I am trying to make an animated flag by manipulating vertex positions every frame. I got the motion done in case there is wind. I now need a transition to when there is no wind. The image below shows on the left the geometry of the flag and on the right the geometry when there is no wind.

flag.jpg

I can't figure out how to get the correct vertex positions for the right pic. Below is some code with comments:

// j represents the rows from the bottom upwards (the real mesh has 21 rows)
j = 0;
// k represents the columns from left to right (the real mesh has 21 columns)
k = 0;

// WidthStep represents the width between 2 vertices horizontally
widthStep = 0.05;

// heightStep represents the height between 2 vertices vertically
heightStep = 0.05;

// adjust value (0 for left image up to 1 for the right image)
adjustVar = 1;

for(i = 0; i < vertices.length;i++){

// code for the left image
// height = j * heightStep;
// width = k * widthStep;

// the code for the right image must have the same setup but code added to represent the wind still image, using a variable with a value between 0 and 1 will then result in the wind still geometry when this var has value 1

height = j * heightStep + (??????? * adjustVar);
width = k * widthStep + (?????? * adjustVar);


if(k == 21){ k = 0; j++}
else k++;
}
}

My theory:

The space between vertices horizontally should gradually decrease. The space between the first 2 vertices is equal to "widthStep" for the bottom vertices (CD), the x distance between C and D should be equal to the height of the flag. This should gradually decrease to about 0 for the top vertices (AB). How can you get the x value of each vertex based on this?

I can't get my head around at all regarding calculating the y values! eek

Anyone into this sort of stuff and knows how to do this?

Thanks,
Raoul

Board footer

Powered by FluxBB