POV-Ray : Newsgroups : povray.general : Flapping wings? : Re: Flapping wings? Server Time
7 Aug 2024 09:20:16 EDT (-0400)
  Re: Flapping wings?  
From: Josh English
Date: 11 Oct 2001 15:15:16
Message: <3BC5EF4E.CFCBD22B@spiritone.com>
Mahalis wrote:

> How would I make wings on an object flap at a certain speed relative to the
> clock?
> ex:
> #declare flapSpeed=50;
> object{Wing rotate ???}

The simple solution goes something like this:
#declare min_angle = -45;
#declare max_angle = 45;
#declare center_angle = (min_angle + max_angle)/2;
#declare amplitude = abs(max_angle - center_angle);

#declare wing_angle = center_angle + cos(clock)*amplitude;

This would be a constant motion up and down, but most flapping requires a
shorter downstroke and a longer upstroke, so you can make a few adjustments:

#declare frac_clock = clock - int(clock); // The wave works between 0 and 1,
but not between 1 and 2
#declare wing_angle = center_angle + cos(pow(frac_clock,0.8))*amplitude;

This creates a slightly more realistic flapping motion. I recommend values
between 0.5 and 1. The closer to 1 you get, the smoother the flapping.

--
Josh English
eng### [at] spiritonecom
The POV-Ray Cyclopedia http://www.spiritone.com/~english/cyclopedia/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.