Point Clipping: Min, Min Max, Max
Point Clipping: Min, Min Max, Max
Point Clipping: Min, Min Max, Max
Clipping a point from a given window is very easy. Consider the following figure,
where the rectangle indicates the window. Point clipping tells us whether the given
point X,YX,Y is within the given window or not; and decides whether we will use the
minimum and maximum coordinates of the window.
The X-coordinate of the given point is inside the window, if X lies in between Wx1 ≤
X ≤ Wx2. Same way, Y coordinate of the given point is inside the window, if Y lies in
between Wy1 ≤ Y ≤ Wy2.
Line Clipping
The concept of line clipping is same as point clipping. In line clipping, we will cut the
portion of line which is outside of window and keep only the portion that is inside the
window.
Algorithm
Let Ni be the outward normal edge Ei. Now pick any arbitrary point P Ei on edge
Ei then the dot product Ni.[Ptt – PEi] determines whether the point P tt is “inside the
clip edge” or “outside” the clip edge or “on” the clip edge.
The point Ptt is inside if Ni.[Ptt – PEi] < 0
The point Ptt is outside if Ni.[Ptt – PEi] > 0
The point Ptt is on the edge if Ni.[Ptt – PEi] = 0 IntersectionpointIntersectionpoint
Ni.[Ptt – PEi] = 0
Ni.[ P0 + t(P1 - P0) – PEi] = 0 ReplacingP(tReplacingP(t with P0 + t(P1 - P0))
Ni.[P0 – PEi] + Ni.t[P1 - P0] = 0
Ni.[P0 – PEi] + Ni∙tD = 0 (substituting D for [P1 - P0])
Ni.[P0 – PEi] = - Ni∙tD
The equation for t becomes,
t=Ni.[Po−PEi]−Ni.Dt=Ni.[Po−PEi]−Ni.D
It is valid for the following conditions −
Ni ≠ 0 errorcannothappenerrorcannothappen
D ≠ 0 (P1 ≠ P0)
Ni∙D ≠ 0 (P0P1 not parallel to Ei)
Polygon
Clipping SutherlandHodgmanAlgorithmSutherla
ndHodgmanAlgorithm
A polygon can also be clipped by specifying the clipping window. 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. These new vertices are used to clip the polygon against
right edge, top edge, bottom edge, of the clipping window as shown in the following
figure.
This clipping method is based on characters rather than entire string. In this method
if the string is entirely inside the clipping window, then we keep it. If it is partially
outside the window, then −
You reject only the portion of the string being outside
If the character is on the boundary of the clipping window, then we discard that entire
character and keep the rest string.
The following figure shows text clipping −
This clipping method is based on characters rather than the entire string. In this
method if the string is entirely inside the clipping window, then we keep it. If it is
partially outside the window, then
You reject only the portion of string being outside.
If the character is on the boundary of the clipping window, then we discard only that
portion of character that is outside of the clipping window.
Bitmap Graphics
A bitmap is a collection of pixels that describes an image. It is a type of computer
graphics that the computer uses to store and display pictures. In this type of
graphics, images are stored bit by bit and hence it is named Bit-map graphics. For
better understanding let us consider the following example where we draw a smiley
face using bit-map graphics.
Now we will see how this smiley face is stored bit by bit in computer graphics.
By observing the original smiley face closely, we can see that there are two blue
lines which are represented as B1, B2 and E1, E2 in the above figure.
In the same way, the smiley is represented using the combination bits of A4, B5,
C6, D6, E5, and F4 respectively.
The main disadvantages of bitmap graphics are −
We cannot resize the bitmap image. If you try to resize, the pixels get blurred.
Colored bitmaps can be very large.