Bending a Mesh about a Circle
Does anyone have any references on how to deform a mesh about a circle''s circumference? Kind of like spherical uv wrapping of a texture but for a finite arc given as the length of the mesh along the x axis, and only in the x-z plane.
To help you visualize, I''m thinking of using this to animate a fish body mesh as the fish turns. The greater the turn angle the more the fish mesh is bent, such that at 90 degrees the fish mesh would be deformed around a circle with a radius equal to half the total mesh length. At 0 degrees the fish mesh would not be deformed at all, which would be equivalent to a circle of infinite radius.
If you''ve got a fixed arc length and a varying angle (assuming the angle of turning the angle of the arc) then the arc length, angle and radius are related by
s = r theta
and so
r = s / theta
s = the length of the arc, i.e the size of your piece of mesh in the x direction
theta = the angle it''s being turned through, in radians
r = the radius of the circle generated
Obviously for theta = 0 this will fail, but as you note this corresponds to a straight line so can be easily special cased.
You can use this to plot points with code like
for (angle = 0; angle < theta; angle += theta / num_steps)
{
x = r * ( 1 - cos (angle));
y = r * sin (angle);
}
The (1 - cos(angle)) ensures one end is fixed as it curves.
s = r theta
and so
r = s / theta
s = the length of the arc, i.e the size of your piece of mesh in the x direction
theta = the angle it''s being turned through, in radians
r = the radius of the circle generated
Obviously for theta = 0 this will fail, but as you note this corresponds to a straight line so can be easily special cased.
You can use this to plot points with code like
for (angle = 0; angle < theta; angle += theta / num_steps)
{
x = r * ( 1 - cos (angle));
y = r * sin (angle);
}
The (1 - cos(angle)) ensures one end is fixed as it curves.
John BlackburneProgrammer, The Pitbull Syndicate
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement