Advertisement

Bending a Mesh about a Circle

Started by November 27, 2002 11:22 AM
1 comment, last by Darrell L 22 years, 2 months ago
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.
John BlackburneProgrammer, The Pitbull Syndicate
Advertisement
That''s basically what I have now. But I didn''t consider the fixed end aspect. Thanks.

I found the "real" problem anyway. I wasn''t taking into account that the mesh might not be centered around the origin, so my wrapping was distorting.

This topic is closed to new replies.

Advertisement