Group B Assignment 1: Title of The Assignment
Group B Assignment 1: Title of The Assignment
Group B
Assignment 1
Objective of the Assignment: Write C++ program to draw 2-D object and perform following basic
transformations: Scaling, Translation, Rotation. Apply the concept of operator
overloading
Prerequisite:
1. Basic programming skills of C++
2. Characteristic of 2D object
3. Graphics Drawing primitives for closed figure
4. Concept of operator overloading of Object Oriented Programming
Theory:
Transformation means changing some graphics into something else by applying rules. We can
have various types of transformations such as translation, scaling up or down, rotation, shearing,
reflection etc. When a transformation takes place on a 2D plane, it is called 2D transformation.
Transformations play an important role in computer graphics to reposition the graphics on the
screen and change their size or orientation. Translation, Scaling and Rotation are basic
transformations.
1) TRANSLATION:
A translation moves an object to a different position on the screen. You can translate a point in 2D
by adding translation coordinate or translation vector (Tx, Ty) to the original coordinates.
Consider Initial coordinates of the object O = (Xold, Yold)
New coordinates of the object O after translation = (Xnew, Ynew)
Translation vector or Shift vector = (Tx, Ty)
DVVPCOE, Ahmednagar
Department of Computer Science & Design Engineering OOPCGL
This translation is achieved by adding the translation coordinates to the old coordinates of the object
as-
Xnew = Xold + Tx (This denotes translation towards X axis)
Ynew = Yold + Ty (This denotes translation towards Y axis)
In rotation, we rotate the object at particular angle θ (theta) from its original position.
2) ROTATION:
Consider
Initial coordinates of the object O = (Xold, Yold)
Initial angle of the object O with respect to origin = Φ
Rotation angle = θ
New coordinates of the object O after rotation = (Xnew, Ynew)
DVVPCOE, Ahmednagar
Department of Computer Science & Design Engineering OOPCGL
3) SCALING:
Scaling transformation is used to change the size of an object. In the scaling process,
you either expand or compress the dimensions of the object. Scaling can be achieved by
multiplying the original coordinates of the object with the scaling factor (Sx, Sy). If scaling
factor > 1, then the object size is increased. If scaling factor < 1, then the object size is
reduced. Consider
Initial coordinates of the object O = (Xold, Yold)
Scaling factor for X-axis = Sx
Scaling factor for Y-axis = Sy
New coordinates of the object O after scaling = (Xnew, Ynew)
DVVPCOE, Ahmednagar
Department of Computer Science & Design Engineering OOPCGL
4) HOMOGENEOUS COORDINATES
Matrix multiplication is easier to implement in hardware and software as
compared to matrix addition. Hence we want to replace matrix addition by
multiplication while performing transformation operations. So the solution is
homogeneous coordinates , which allows us to express all transformations (including
translation) as matrix multiplications.
To obtain homogeneous coordinates we have to represent transformation
matrices in 3x3 matrices instead of 2x2. For this we add dummy coordinate. Each 2
dimensional position (x,y) can be represented by homogeneous coordinate as (x,y,1).
x' 1 0 Tx x
y' = 0 1 T y
y
DVVPCOE, Ahmednagar
Department of Computer Science & Design Engineering Subject: OOPCGL
Group B
Assignment 2
Problem Statement : Write C++ program to draw Generate fractal patterns using Koch Curve
Theory :
In computer graphics, we often need to draw different types of objects onto the screen.Objects are
not flat all the time and we need to draw curves many times to draw an object.
Types of Curves
A curve is an infinitely large set of points. Each point has two neighbors except endpoints. Curves can
be broadly classified into three categories − explicit, implicit, and parametric curves.
Implicit Curves
Implicit curve representations define the set of points on a curve by employing a procedure that can test
to see if a point in on the curve. Usually, an implicit curve is defined by an implicit function of the form
–
f(x, y) = 0
It can represent multivalued curves (multiple y values for an x value). A common example is the circle,
whose implicit representation is
x2 + y2 - R2 = 0
Explicit Curves
A mathematical function y = f(x) can be plotted as a curve. Such a function is the explicit representation
of the curve. The explicit representation is not general, since it cannot represent vertical lines and is
also single-valued. For each value of x, only a single value of y is normally computed by the function.
Parametric Curves
Curves having parametric form are called parametric curves. The explicit and implicit curve
representations can be used only when the function is known. In practice the parametric curves are used.
A two-dimensional parametric curve has the following form −
The functions f and g become the (x, y) coordinates of any point on the curve, and the points are obtained
when the parameter t is varied over a certain interval [a, b], normally [0, 1].
DVVPCOE, Ahmednagar
Department of Computer Science & Design Engineering Subject: OOPCGL
Koch Curve
Fractals are geometric objects. Many real-world objects like ferns are shaped like fractals. Fractals
are formed by iterations. Fractals are self-similar.
In computer graphics, we use fractal functions to create complex object
The object representations uses Euclidean-geometry methods; that is, object shapes were described
with equations. These methods are adequate for describing manufactured objects: those that have
smooth surfaces and regular shapes. But natural objects, such as mountains and clouds, have
irregular or fragmented features, and Euclidean methods do not realistically model these objects.
Natural objects can be realistically described with fractal-geometry methods, where procedures
rather than equations are used to model objects.
In computer graphics, fractal methods are used to generate displays of natural objects and
visualizations . The self-similarity properties of an object can take different forms, depending on
the choice of fractal representation.
In computer graphics, we use fractal functions to create complex objects A mountain outlined
against the sky continues to have the same jagged shape as we view it from a closer and closer. We
can describe the amount of variation in the object detail with a number called the fractal dimension.
Examples: In graphics applications, fractal representations are used to model terrain, clouds, water,
trees and other plants, feathers, fur, and various surface textures, and just to make pretty patterns. In
other disciplines, fractal patterns have been found in the distribution of stars, river islands, and
moon craters; in rain fields; in stock market variations; in music; in traffic flow; in urban property
utilization; and in the boundaries of convergence regions for numerical- analysis techniques
DVVPCOE, Ahmednagar
Department of Computer Science & Design Engineering Subject: OOPCGL
Conclusion : In this way we have implemented objects like waves using Koch curve generation
techniques.
DVVPCOE, Ahmednagar
Department of Computer Science & Design Engineering OOPCGL
Group C
Assignment 2
Objective of the Assignment: Write C++ program to draw man walking in the rain with
an umbrella. Apply the concept of polymorphism.
Prerequisite:
1. Basic programming skills of C++
2. Graphics Primitive for C++
3. Basic steps to generate animation
Theory:
Computer Animation:
• It is the process used for generating animated images (moving images) using computer
graphics.
• Animators are artists who specialize in the creation of animation.
• From Latin animātiō, "the act of bringing to life"; from animō ("to animate" or "give life
to") and -ātiō ("the act of").
1. Layout of Storyboard: Storyboard layout is the action outline utilized to illustrate the
motion sequence as a set of storyboard comprises a set of rough sketches or a list of basic
concepts for the motion.
2. Definition of Object &Path : The object definition is specified for all participant objects
in action. The objects can be explained in terms of fundamental shapes, related movements
or movement with shapes.
3. Specification of Key Frame: this is the detailed drawing of the scene at an exact time in
DVVPCOE, Ahmednagar
Department of Computer Science & Design Engineering OOPCGL
the animation sequence. Inside each key frame, all objects are positioned as per to time for
that frame. Several key frames are selected at the extreme positions in the action; More key
frames are given for intricate motion than for easy, slowly varying motions.
4. In-between frames Generation: In-among frames are the middle frames among the key
frames. In common, film needs twenty-four frames per second, and graphic terminals are
refreshed on the rate of 30 to 60 frames per second. Classically the time interval for the
motion is set up hence there are 3 to 5 among for each pair of key frames. Based upon the
speed identified for the motion, several key frames can be duplicated.
Motion Specifications
In Various ways in which motions of objects can be specified as:
• Direct Motion Specification: Here the rotation angles and translation vectors are explicitly
given. Then the geometric transformation matrices are applied to transform coordinate
positions. We can approximate the path of a bouncing ball with a damped, rectified, sine
curve
• Goal-Directed Systems : We can specify the motions that are to take place in general
terms that abstractly describe the actions. These systems are referred to as goal directed
because they determine specific motion parameters given the goals of the animation.
For example, We could specify that we want an object to "walk " or to "run" to a particular
destination. Or We could state that we want an object to "pick up " some other specified
object.
DVVPCOE, Ahmednagar
Department of Computer Science & Design Engineering OOPCGL
DVVPCOE, Ahmednagar