Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
UNIT-III
1. UNIT - III
❖Basic transformation
❖Matrix representations
❖Composite transformations
❖Window to view port Co-ordinate transformation
❖Clipping
❖Point clipping
❖Line clipping
❖Cohen-Sutherland line clipping
❖Liang Barsky line clipping algorithm
❖Polygon clipping
2. BASIC TRANSFORMATION
❖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, etc.
❖When a transformation takes place on a 2D plane, it is called 2D transformation.
❖Two essential aspects of transformation are given below:
❖Each transformation is a single entity. It can be denoted by a unique name or symbol.
❖It is possible to combine two transformations, after connecting a single transformation is
obtained, e.g., A is a transformation for translation. The B transformation performs scaling.
The combination of two is C=AB. So C is obtained by concatenation property.
6. 2D TRANSLATION
❖ One of rigid-body transformation, which moves object without deformation.
❖ Translate an object by adding offsets to coordinates to generate new coordinates
positions.
❖ P’=P+T
❖ Translation moves the object without deformation.
7. SCALING
❖ A Scaling transformation alters the size of an objects.
❖ This operations can be carried out for polygons by multiplying the coordinate
values(x , y) of each vertex by scaling factors sx and sy to produce the
transformed coordinates(x’ , y’):
❖ Scaling factors sx scales objects in the x direction, and sy in the y direction
8. ❖ A two-dimension rotation is applied to an object
by re positioning it along a circular path in the xy
plane.
❖ To generate a rotation, we specify a rotation
angle θ and the position (x , y) of the rotation
point (or pivot point) about which the object is to
be rotated.
❖ Positive values for the rotation angle define
counter clockwise rotation about the pivot point.
❖ Negative values rotate objects in the clock
direction.
SCALING
9. Distorts the shape of an object such that the transformed shape
Appears as if the object were composed of internal layers that had been
caused to slide over each other.
OTHER TRANSFORMATIONS: SHEAR
11. MATRIX REPRESENTATIONS
❖Matrix representation is a method used by a computer language to store matrices of
more than one dimension in memory. ... Fortran uses "Column Major", in which all the
elements for a given column are stored contiguously in memory. C uses "Row Major",
which stores all the elements for a given row contiguously in memory.
❖Homogeneous coordinates are ubiquitous in computer graphics because they allow
common vector operations such as translation, rotation, scaling and perspective
projection to be represented as a matrix by which the vector is multiplied.
12.
13.
14.
15. WINDOW TO VIEW PORT CO-ORDINATE
TRANSFORMATION
❖Window to Viewport
Transformation is the
process of transforming a
2D world-coordinate
objects to device
coordinates. Objects inside
the world or clipping
window are mapped to the
viewport which is the area
on the screen where world
coordinates are mapped to
be displayed.
16. GENERAL TERMS:
❖World coordinate – It is the Cartesian coordinate w.r.t which we define the diagram,
like Xwmin, Xwmax, Ywmin, Ywmax
❖Device Coordinate –It is the screen coordinate where the objects is to be displayed,
like Xvmin, Xvmax, Yvmin, Yvmax
❖Window –It is the area on world coordinate selected for display.
❖ViewPort –It is the area on device coordinate where graphics is to be displayed.
17. MATHEMATICAL CALCULATION OF WINDOW TO VIEWPORT:
❖It may be possible that the size of the Viewport is much smaller or
greater than the Window. In these cases, we have to increase or decrease
the size of the Window according to the Viewport and for this, we need
some mathematical calculations.
❖(xw, yw): A point on Window
❖ (xv, yv): Corresponding point on Viewport
❖we have to calculate the point (xv, yv)
18.
19. CLIPPING
❖Clipping Any Procedure that identifies those portions of a picture that are either inside or outside of a specified
region of a space is referred to as a Clipping algorithm or simply Clipping . The region against which an object is
to clipped is called a Clip Window.
❖Types of Clipping:
❖Point Clipping.
❖Line Clipping.
❖Area Clipping (Polygon)
❖Curve Clipping.
❖Text Clipping.
❖Exterior Clipping.
20. POINT CLIPPING:
❖Point Clipping is used to determining, whether the point is inside the
window or not. For this following conditions are checked.
❖x ≤ x max
❖x ≥ x min
❖y ≤ y max
❖y ≥ y min
21. LINE CLIPPING:
❖It is performed by using the line clipping algorithm. The line clipping algorithms
are:
❖Cohen Sutherland Line Clipping Algorithm
❖Midpoint Subdivision Line Clipping Algorithm
❖Liang-Barsky Line Clipping Algorithm
22. COHEN–SUTHERLAND ALGORITHM
❖The Cohen–Sutherland algorithm is a computer-graphics algorithm used
for line clipping. The algorithm divides a two-dimensional space into 9 regions and
then efficiently determines the lines and portions of lines that are visible in the
central region of interest (the viewport).
❖The algorithm was developed in 1967 during flight-simulator work by Danny
Cohen and Ivan Sutherland.
23. ALGORITHM
❖The algorithm includes, excludes or partially includes the line based on whether:
❖Both endpoints are in the viewport region (bitwise OR of endpoints = 00): trivial accept.
❖Both endpoints share at least one non-visible region, which implies that the line does not cross the
visible region. (bitwise AND of endpoints ≠ 0): trivial reject.
❖Both endpoints are in different regions: in case of this nontrivial situation the algorithm finds one of the
two points that is outside the viewport region (there will be at least one point outside). The intersection of
the outpoint and extended viewport border is then calculated (i.e. with the parametric equation for the line),
and this new point replaces the outpoint. The algorithm repeats until a trivial accept or reject occurs.
❖The Cohen–Sutherland algorithm can be used only on a rectangular clip window.
24. ❖The numbers in the figure below are called out
codes. An out code is computed for each of the two
points in the line. The out code will have 4 bits for
two-dimensional clipping, or 6 bits in the three-
dimensional case. The first bit is set to 1 if the point
is above the viewport. The bits in the 2D out code
represent: top, bottom, right, left. For example, the
out code 1010 represents a point that is top-right of
the viewport.
25. LIANG BARSKY LINE CLIPPING
❖In computer graphics, the Liang–Barsky algorithm (named after You-Dong Liang and Brian A. Barsky)
is a line clipping algorithm.
❖The Liang–Barsky algorithm uses the parametric equation of a line and inequalities describing the range of
the clipping window to determine the intersections between the line and the clip window.
❖With these intersections it knows which portion of the line should be drawn. This algorithm is significantly
more efficient than Cohen–Sutherland.
❖The idea of the Liang–Barsky clipping algorithm is to do as much testing as possible before computing line
intersections.
26.
27. POLYGON CLIPPING
❖A set of connected lines are considered as polygon;
❖polygons are clipped based on the window and the portion which is inside the window is kept as it is and the
outside portions are clipped.
❖The polygon clipping is required to deal different cases.
❖The clip boundary determines the visible and invisible regions of polygon clipping and it is categorized as four.
• Visible region is wholly inside the clip window – saves endpoint
• Visible exits the clip window – Save the interaction
• Visible region is wholly outside the clip window – nothing to save
• Visible enters the clip window – save endpoint and intersection
28.
29. SUTHERLAND–HODGMAN POLYGON CLIPPING
❖Sutherland Hodgeman polygon clipping algorithm is used for polygon clipping. In
this algorithm, all the vertices of the polygon are clipped against each edge of
the clipping window.
❖First the polygon is clipped against the left edge of the polygon window to get new
vertices of the polygon.
❖A convex polygon and a convex clipping area are given. The task is to clip
polygon edges using the Sutherland–Hodgman Algorithm. Input is in the form
of vertices of the polygon in clockwise order.
30. We illustrate this algorithm by processing the area in
figure against the left window boundary.
❖ Vertices 1 and 2 are outside of the boundary.
❖ Vertex 3, which is inside, 1' and vertex 3 are
saved.
❖ Vertex 4 and 5 are inside, and they also saved.
❖ Vertex 6 is outside, 5' is saved. Using the five
saved points, we would repeat the process for the
next window boundary.
SUTHERLAND-HODGMAN POLYGON CLIPPING (EXAMPLE)
31. ❖Clip a polygon by processing the polygon boundary against each window edge. (Left, Top, Bottom,
Right).
❖ Apply four cases to process all polygon edges to produce sequence of vertices. This sequence of
vertices will make a bounded area.
❖Beginning with the initial set of polygon vertices, we could first clip the polygon against the left
rectangle boundary to produce a new sequence of vertices. The new set of vertices could be
successively passed to a right boundary clipper, a bottom boundary clipper. and a top boundary
clipper.
STEPS TO SOLVE POLYGON CLIPPING
32. CURVE CLIPPING
❖Curve Clipping involves complex procedures as compared to lineclipping. Curve
clipping requires more processing than for object with linear boundaries. Consider
window which is rectangular in shape. The circle is to consider against rectangle
window.
❖The bounding rectangle for a circle Or other curved object can be used first to test for
overlap with a rectangular clip Window
❖If the rectangle is determined to be completely outside the window, we discard the
object
33. If both the above tests fails we use other computation saving
approaches depending upon type of object
• Circle: Use coordinate extent of individual quadrant, then octant if required.
• Ellipse: Use coordinate extent of individual quadrant.
• Point: Use point clipping
CURVE CLIPPING
34. TEXT CLIPPING
❖Several methods are available for clipping of text. Clipping method is dependent on
the method of generation used for characters. A simple method is completely
considered, or nothing considers method. This method is also called as all or none. If
all characters of the string are inside window, then we will keep the string, if a string
character is outside then whole string will be discarded in fig (a).
❖Another method is discarded those characters not completely inside the window. If
a character overlap boundary of window. Those will be discarded in fig (b).
❖In fig (c) individual character is treated. Character lies on boundary is discarded as
which it is outside the window.