0% found this document useful (0 votes)
93 views1 page

Algorithm WPS Office

The algorithm defines a viewing window and assigns region codes to the start and end points of a line. It checks if the line lies fully within, partially within, or outside the window by performing a logical AND operation on the region codes. If the line is partially within the window, it finds the intersection point where the line crosses the window boundary using formulas based on the line's slope and the boundary edge. It overwrites the endpoint and repeats this process until the line is fully clipped within the window.

Uploaded by

Ujwal Jaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views1 page

Algorithm WPS Office

The algorithm defines a viewing window and assigns region codes to the start and end points of a line. It checks if the line lies fully within, partially within, or outside the window by performing a logical AND operation on the region codes. If the line is partially within the window, it finds the intersection point where the line crosses the window boundary using formulas based on the line's slope and the boundary edge. It overwrites the endpoint and repeats this process until the line is fully clipped within the window.

Uploaded by

Ujwal Jaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Algorithm

1) First, define a window or View plane. Get coordinates from the user of a line.

2) Initialize the region code for initial and end coordinates of a line to 0000.

3) Check whether the line lies within, partially or outside the window.

Now, Assign the region code for both the initial and end coordinates.

After Assigning, If both the endpoints give 0000, then the line is completely within the window.

Else perform AND operation, if the result is not 0000, then the line is not inside the window and that line
would not be considered for clipping.

Else the line is partially inside the window.

4) After confirming the line is partially inside the window, the next step is to find the intersection point
at the window boundary. By using the following formula:

If the line passes through the top,

x=x+(W_ymax-y)/slope ;

y=W_ymax;

If the line passes through the bottom,

x=x+(W_ymin-y)/slope ;

y=W_ymin;

if the line passes through the left region,

y=y+(W_xmin-x)*slope,

x1=W_xmin;

if the line passes through the right region,

y1=y1+(W_xmax-x1)*slope ,

x1=W_xmax

5) Now, overwrite the endpoint with a new one and update it.

6) Repeat 4th step till your line doesn’t get clipped completely.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy