Vous êtes sur la page 1sur 14

Simulation of Wind effects on trees in C

Introduction
The simulation of wind is an area of vast interest in aerodynamic engineering,
computational fluid dynamics (CFD), and animation or visualization of fluids in computer
graphics. The demand for increasingly realistic visual simulations of complex phenomena is
tremendous. The ultimate goal is to bring the graphics and animations alive so that trees are
blown in the wind, flags flap, fluids flow, and hair flies. Faithful simulation of these effects
involve three essential elements: a flow field, object model, and the coupling between
them. The project is motivated by the recognition that to support interactive simulations or
respond to events occurring in the scene, each of these three elements must be computed in realtime. Further-more, exhibiting realistic dynamics under the broadest range of conditions, requires
the use of models that are as physically accurate as possible. And, since boundary conditions
largely define a flow field while also playing an extremely important role in object dynamics and
coupling, it is essential to be able to handle complex shaped and moving boundaries.
What is wind ?
Wind is the flow of gases on a large scale. On the surface of the Earth, wind consists of
the bulk movement of air. In meteorology, winds are often referred to according to their strength,
and the direction from which the wind is blowing. Short bursts of high speed wind are termed
gusts. Strong winds of intermediate duration (around one minute) are termed squalls. Longduration winds have various names associated with their average strength, such as breeze, gale,
storm, and hurricane. The two main causes of large-scale atmospheric circulation are the
differential heating between the equator and the poles, and the rotation of the planet (Coriolis
effect). Within the tropics, thermal low circulations over terrain and high plateaus can drive
monsoon circulations. In coastal areas the sea breeze/land breeze cycle can define local winds; in
areas that have variable terrain, mountain and valley breezes can dominate local winds.

Page 1

Simulation of Wind effects on trees in C

Applications
1. Modeling and Simulating Wind Turbine Effects - Keeping radar systems uninhibited
by manmade obstructions is vital to homeland security efforts. The increasing use of
wind farms as a source of power has necessitated analysis of their potential impact on
these systems. The large, rapidly moving (tip velocity up to 170 mph) blades of wind
farm turbines return Doppler shifted radar signals that mimic aircraft or even a stationary
tornado. This Doppler interference results in degraded radar performance that could make
aircraft or weather events nearly undetectable.
2. Wind Effect on growth of plants- To enhance the realism of virtual plants, the effects of
wind on the motion and growth of plants should be modeled. The effects of wind blowing
through trees and especially its effects on branches have been extensively studied in
computer animation. To date, only a few computer animation researchers have studied the
effect of wind on leaf motion, with no consideration of the effects of wind on the growth
of virtual plants.
3. Study of deformation of objects due to wind We can model force fields describing air
motion and show how these models can be augmented to exhibit interaction with
deformable thin objects such as textiles
4. Visualization of fluids We can study the flow of fluids in the presence of wind
depending upon the speed of wind and the viscosity of the fluid.
5. Study Aerodynamic Effects It is very useful to study the effects of air on flying
objects like the rockets or airplanes and ensure their safety in air. These effects can be
simulated and presented to the trainees.
6. Weather forecasting and Storm analysis Animation models can be designed to study
the force and direction of the wind flow during the formation of cyclones and tornadoes.
The destruction caused by the force of the wind can be estimated and simulated using
such animated modules.
7. Change in Landforms Models can be made to simulate the erosion caused by winds to
mountains and sand dunes. The motion of the sand in desert can be studied and animated
as per the direction of windflow. The formation of landforms and the role of wind can be
studied too.

System Flowchart
START
Page 2

Simulation of Wind effects on trees in C

Show the scene

Start timer

Move tree to left side

No

Time up?

Yes

Start new timer

Move tree to right side

No

Time up?
Yes

END

Fig. 1 : Flowchart of the system


The flowchart symbols are as follows-

Page 3

Simulation of Wind effects on trees in C

1. Start/End symbol An oval shape is used to mark the end or start point.

2. Arrows The line is a connector that shows relationship between the representative
shapes

3. Input/Output The parallelogram represents the input or output instruction

4. Process The rectangle represents a process

5. Decision A diamond shape is used to represent decision

Languages and tools


HARDWARE

Page 4

Simulation of Wind effects on trees in C

A Desktop Computer with configuration given belowOperating system


:
Windows XP
RAM
:
1 GB
Processor
:
2.3 Ghz Intel Dual Core Processor
Screen Resolution
:
SVGA
Keyboard
:
I-ball 102 Keys wired Keyboared
Mouse
:
I-ball wired optical mouse
SOFTWARE
Turbo C Compiler
Microsoft Notepad
C Language
C is a general-purpose, imperative computer programming language, supporting
structured programming, lexical variable scope and recursion, while a static type system prevents
many unintended operations. By design, C provides constructs that map efficiently to typical
machine instructions, and therefore it has found lasting use in applications that had formerly
been coded in assembly language, including operating systems, as well as various application
software for computers ranging from supercomputers to embedded systems.
C was originally developed by Dennis Ritchie between 1969 and 1973 at Bell Labs,[5]
and used to re-implement the Unix operating system.[6] It has since become one of the most
widely used programming languages of all time,[7][8] with C compilers from various vendors
available for the majority of existing computer architectures and operating systems. C has been
standardized by the American National Standards Institute (ANSI) since 1989 (see ANSI C) and
subsequently by the International Organization for Standardization (ISO).
C Graphics programming is very easy and interesting. You can use graphics programming
for developing your own games, in making projects, for animation etc. It's not like traditional C
programming in which you have to apply complex logic in your program and then you end up
with a lot of errors and warnings in your program. In C graphics programming you have to use
standard library functions ( need not worry if you don't know functions ) to get your task done.
Just you pass arguments to the functions and it's done. On this website you will find almost all
functions with detailed explanation and a sample program showing the usage of a function. To
make things easy you are provided with executable files which you can download and execute.
Firstly you should know the function initgraph which is used to initialize the graphics mode . To
Page 5

Simulation of Wind effects on trees in C

initialize graphics mode we use initgraph function in our program. initgraph function is present
in "graphics.h" header file, so your every graphics program should include "graphics.h" header
file.
C is widely used for "system programming", including implementing operating systems
and embedded system applications, due to a combination of desirable characteristics such as code
portability and efficiency, ability to access specific hardware addresses, ability to pun types to
match externally imposed data access requirements, and low run-time demand on system
resources. C can also be used for website programming using CGI as a "gateway" for information
between the Web application, the server, and the browser. Some reasons for choosing C over
interpreted languages are its speed, stability, and near-universal availability.
One consequence of C's wide availability and efficiency is that compilers, libraries and
interpreters of other programming languages are often implemented in C. The primary
implementations of Python, Perl 5 and PHP, for example, are all written in C.
Due to its thin layer of abstraction and low overhead, C allows efficient implementations
of algorithms and data structures, which is useful for programs that perform a lot of computations.
For example, the GNU Multiple Precision Arithmetic Library, the GNU Scientific Library,
Mathematica and MATLAB are completely or partially written in C.
C is sometimes used as an intermediate language by implementations of other languages.
This approach may be used for portability or convenience; by using C as an intermediate
language, it is not necessary to develop machine-specific code generators. C has some features,
such as line-number preprocessor directives and optional superfluous commas at the end of
initializer lists, which support compilation of generated code. However, some of C's shortcomings
have prompted the development of other C-based languages specifically designed for use as
intermediate languages, such as C--.
C has also been widely used to implement end-user applications, but much of that
development has shifted to newer, higher-level languages.
Microsoft Notepad
Micosoft Notepad - Microsoft Notepad is a simple text editor for Microsoft Windows and a basic
text-editing program which enables computer users to create documents. It has been included in
all versions of Microsoft Windows since Windows 1.0 in 1985.
Notepad is a common text-only (plain text) editor. The resulting filestypically saved with the
.txt extensionhave no format tags or styles, making the program suitable for editing system files
to use in a DOS environment and, occasionally, source code for later compilation or execution,
Page 6

Simulation of Wind effects on trees in C

usually through a command prompt. It is also useful for its negligible use of system resources;
making for quick load time and processing time, especially on under-powered hardware. Notepad
supports both left-to-right and right-to-left based languages. Unlike WordPad, Notepad does not
treat newlines in Unix- or Mac-style text files correctly. Notepad offers only the most basic text
manipulation functions, such as finding text. Only newer versions of Windows include an updated
version of Notepad with a search and replace function. However, it has much less functionality in
comparison to full-scale editors.
In all versions of Windows, Notepad uses a built-in window class named EDIT.
Older versions included with Windows 95, Windows 98, Windows Me and Windows 3.1, imposed
a 64 K limit on file size, which was an operating system limit of the EDIT class. Up to Windows
95, Fixedsys was the only available display font for Notepad. Windows NT 4.0 and 98 introduced
the ability to change this font. As of Windows 2000, the default font was changed to Lucida
Console. The font setting, however, only affects how the text is shown to the user and how it is
printed, not how the file is saved to disk. The default font was changed to Consolas on Windows
8. Up to Windows Me, there were almost no keyboard shortcuts and no line-counting feature.
Starting with Windows 2000, shortcuts for common tasks like new, open and save were added, as
well as a status-bar with a line counter (available only when word-wrap is disabled). In the
Windows NT-based versions of Windows, Notepad can edit traditional 8-bit text files as well as
Unicode text files (both UTF-8 and UTF-16, and in case of UTF-16, both little-endian and bigendian).

Project Description
When we start the application, the trees and cloud scene is displayed. The timer is started and the
tree starts to move to left side of screen as shown in the figure.

Page 7

Simulation of Wind effects on trees in C

Fig 2: The swaying of tree in left side

Later on when the timer is up, the motion towards left stops and a new timer is started. Till this
new times is up, the tree continues to move right now. Once the timer ends, the program quits
automatically.

Page 8

Simulation of Wind effects on trees in C

Fig 2: The swaying of tree in right side

We have used following C functions in code1. Line - ine function is used to draw a line from a point(x1,y1) to point(x2,y2) i.e. (x1,y1)
and (x2,y2) are end points of the line. The code given below draws a line.
Declaration :- void line(int x1, int y1, int x2, int y2);
2. Ellipse - Ellipse is used to draw an ellipse (x,y) are coordinates of center of the ellipse,
stangle is the starting angle, end angle is the ending angle, and fifth and sixth parameters
specifies the X and Y radius of the ellipse. To draw a complete ellipse strangles and end
angle should be 0 and 360 respectively.
Declarations of ellipse function :void ellipse(int x, int y, int stangle, int endangle, int xradius, int yradius);

Page 9

Simulation of Wind effects on trees in C

3. Setcolor- In Turbo Graphics each color is assigned a number. Total 16 colors are
available. Strictly speaking number of available colors depends on current graphics mode
and driver.For Example :- BLACK is assigned 0, RED is assigned 4 etc. setcolor function
is used to change the current drawing color.e.g. setcolor(RED) or setcolor(4) changes the
current drawing color to RED. Remember that default drawing color is WHITE.
Declaration :- void setcolor(int color);
4. Arc - arc function is used to draw an arc with center (x,y) and stangle specifies starting
angle, endangle specifies the end angle and last parameter specifies the radius of the arc.
arc function can also be used to draw a circle but for that starting angle and end angle
should be 0 and 360 respectively.
Declaration :- void arc(int x, int y, int stangle, int endangle, int radius);
5. Putimage - putimage function outputs a bit image onto the screen. putimage puts the bit
image previously saved with getimage back onto the screen, with the upper left corner of
the image placed at (left, top). ptr points to the area in memory where the source image is
stored. The op argument specifies a operator that controls how the color for each
destination pixel on screen is computed, based on pixel already on screen and the
corresponding source pixel in memory.
Declaration:- void putimage(int left, int top, void *ptr, int op);
6. Getimage - getimage function saves a bit image of specified region into memory, region
can be any rectangle. getimage copies an image from screen to memory. Left, top, right,
and bottom define the area of the screen from which the rectangle is to be copied, bitmap
points to the area in memory where the bit image is stored.
Declaration:- void getimage(int left, int top, int right, int bottom, void *bitmap);
7. Delay - Delay function is used to suspend execution of a program for a particular time.
Here unsigned int is the number of milliseconds ( remember 1 second = 1000
milliseconds ). To use delay function in your program you should include the dos.h
header file.
Declaration :- void delay(unsigned int);

Page 10

Simulation of Wind effects on trees in C

Results and Discussion


Wind is air in motion. It is produced when atmospheric (air) pressure is higher in one area and
lower in another. The velocity of the wind results from the pressure difference between an area of
high pressure and an area of low pressure, with higher velocities from greater differences. Wind
velocity is characterized by its speed and direction
Plants respond to wind immediately with motion and over time with changes in growth
patterns. Plant motion in response to wind has been studied most thoroughly with respect to
trees. The response of a tree branch or leaf to wind depends upon its tensile strength, the size of
its surface area facing the wind, and its mass. If a branch has a large surface area facing the wind,
a low-tensile strength, and a large mass, it can fracture when the force of the wind exceeds the
strength of the branch. Leaves respond in a similar fashion to branches, although with less
influence from the leafs mass, which in negligible, and more from the surface area.
Branch movement in response to wind is observed as a swaying motion, which is also
evident in leaf movement. In addition, leaves display a twisting motion in response to the wind
and a vibration motion when the wind is tangent to the blade.
Plant growth is affected by wind, among many other environmental factors. Several
studies have been conducted to discover the response of various plant species to wind. One study
observed that elongation was significantly retarded in young plants

Page 11

Simulation of Wind effects on trees in C

Conclusion
To enhance the realism of virtual plants, the effects of wind on the motion and growth of plants
should be modeled. The effects of wind blowing through trees and especially its effects on
branches have been extensively studied in computer animation. To date, only a few computer
animation researchers have studied the effect of wind on leaf motion, with no consideration of
the effects of wind on the growth of virtual plants.
Plants are affected by wind immediately through physical motion and over time through changes
in growth. Wind contact with a plant immediately causes physical motion by bending, swaying,
or twisting the stem or leaves.
We have depicted the effect of wind on the trees. We have shown how the tree moves sideways
under strong wind. This project animates the effect of wind on the motion and growth of stems
and leaves of virtual plants.

Page 12

Simulation of Wind effects on trees in C

Future Scope
We can improve the project in future as1. The project at present works with constant delay which controls the speed of the
simulation. In future, we can extend same project to manage the speed of animation.
2. The project currently shows the swaying of tree mass in left and right direction. In future,
we can simulate it in different directions.
3. We may add different objects along with trees.
4. We can extend this mini project to simulate wind effects on other objects like airplanes,
air balloons, textiles, etc
5. We can improve the simulation details by embedding C language with other languages.
6. Further study is required to detect collisions between plant parts and to add the influence
of petiole and leaf motions to those of the branches.
7. In addition utilization of a global approach to incorporate leaf-petiole-branch interactions
requires investigation.
8. Growth is also influenced by other environmental factors, such as temperature and
nutrient, carbon dioxide, and water availability, which could be incorporated in the
simulation.

Page 13

Simulation of Wind effects on trees in C

References
Books:
1. Let Us C, Yashwant Kanetkar, Infinity Science Press.
2. Graphics Programming in C, Peter Aitken, Foresman Publications.
3. Mastering Graphics Programming, Dawara, Sudhir, Laxmi Publications.
Websites:
1.
2.
3.
4.

www.wikipaedia.org
www.tutorialspoint.com
www.scribd.com
www.ctutorialspoint.com

Index
Introduction.................................................................................................................... 1
System Flowchart............................................................................................................ 4
Languages and tools......................................................................................................... 5
Project Description........................................................................................................... 8
Results and Discussion.................................................................................................... 10
Conclusion................................................................................................................ 11
Future Scope................................................................................................................ 12
References................................................................................................................... 13

Page 14

Vous aimerez peut-être aussi