SlideShare a Scribd company logo
1 of 19
UNIT-5
Computational Geometry
Computational Geometry
• Computational geometry is the branch of computer science that studies algorithms for solving geometric
problems.
• In modern engineering and mathematics, computational geometry has applications in such diverse fields as
computer graphics, Robotics, VLSI design, Computer-Aided Design, Molecular Modeling, Metallurgy,
Manufacturing, Textile Layout, Forestry, and Statistics.
• The input to a computational geometry problem is typically a description of a set of geometric objects
represented as a set of points {pi}, where each pi = (xi, yi) and xi, yi є R. For example, an n-vertex polygon
P is represented by a sequence {p0, p1, p2, . . . , pn-1} of its vertices in order of their appearance on the
boundary of P.
• The output is often a response to a query about the objects, such as
 Whether one segment is clockwise or counter clockwise from another?
 Which way should we turn when traversing two adjoining line segments?
 Whether two line segments intersect?
Computational Geometry
• In this unit, we look at a few computational-geometry algorithms in two dimensions, that is, in the
plane.
• Computational geometry can also apply to three dimensions, and even higher-dimensional spaces,
but such problems and their solutions can be very difficult to visualize
Computational Geometry
Line-segment properties
we shall explore the following questions:
There are no restrictions on the given points.
We can answer each question in O(1) time. Moreover, our
methods use only additions, subtractions, multiplications,
and comparisons. We need neither division nor
trigonometric functions, both of which can be
computationally expensive.
Cross products
• Computing cross products is at the heart of line-segment methods.
• Consider vectors p1 and p2, shown in figure.
• The cross product p1X p2 can be interpreted as the signed area of the parallelogram formed by
the points (0, 0), p1, p2, and p1 + p2 = (x1 + x2, y1 +y2).
Cross products
• An equivalent, but more useful, definition gives the cross product as the determinant of a
matrix.
Cross Products
Cross Products
Question 1
Determine whether a directed segment is in a clockwise direction or in a counterclockwise
direction to with respect to their common endpoint p0.
Solution
1. Map p0 to (0,0), p1 to p1’, p2 to p2’
p1’ = p1 – p0 ,
and
p2’ = p2 –p0 Similarly p2’
Then compute the cross product
Cross Products
Question 2
Cross Products
Question 3
Determining whether two line segments intersect
• To determine whether two line segments intersect, we check whether each segment straddles
the line containing the other.
• A segment straddles a line if point p1 lies on one side of the line and point p2 lies on the
other side.
• Two line segments intersect if and only if either (or both) of the following conditions holds:
1. Each segment straddles the line containing the other.
2. An endpoint of one segment lies on the other segment. (This condition comes from
the boundary case.
Cross products
Question 3
Determining whether two line segments intersect
Determining whether any pair of segments intersects
• Algorithm to determine whether any two line segments in a set of segments intersect or not
using a technique known as “Sweeping”.
• The algorithm runs in O(n log n) time, where n is the number of segments. It determines
whether any two line segments in a set of segments intersect or not.
• It takes (n2) time in the worst case to find all the intersections in a set of n line segments.
• In sweeping, an imaginary vertical sweep line passes through the given set of geometric
objects, usually from left to right.
• We treat the spatial dimension that the sweep line moves across, in this case the x-dimension,
as a dimension of time.
• The line-segment-intersection algorithm considers all the line-segment endpoints in left-to-
right order and checks for an intersection each time it encounters an endpoint.
Determining whether any pair of segments intersects
• To describe and prove correct the line-segment-intersection algorithm for determining
whether any two of n line segments intersect or not, we shall make two simplifying
assumptions.
 First, we assume that no input segment is vertical.
 Second, we assume that no three input segments intersect at a single point.
Determining whether any pair of segments intersects
Ordering segments
• Because we assume that there are no vertical segments, we know that any input segment
intersecting a given vertical sweep line intersects it at a single point.
• Thus, we can order the segments that intersect a vertical sweep line according to the y-
coordinates of the points of intersection.
• To be more precise, consider two segments s1 and s2. We say that these segments are
comparable at x if the vertical sweep line with x-coordinate x intersects both of them.
Determining whether any pair of segments intersects
Ordering segments
Determining whether any pair of segments intersects
Moving the sweep line
Sweeping algorithms typically manage two sets of data:
1. The sweep-line status gives the relationships among the objects that the sweep line intersects.
2. The event-point schedule is a sequence of points, called event points, which we order from left to
right according to their x-coordinates. As the sweep progresses from left to right, whenever the
sweep line reaches the x-coordinate of an event point, the sweep halts, processes the event point,
and then resumes.
3. Changes to the sweep-line status occur only at event points.
If the input contains n segments, we can perform each of the operations INSERT, DELETE, ABOVE, and
BELOW in O(lg n) time using red-black trees.
Determining whether any pair of segments intersects
Segment-intersection pseudocode
The following algorithm takes as input a set S of n line segments, returning the boolean value TRUE if any
pair of segments in S intersects, and FALSE otherwise. A red-black tree maintains the total preorder T .
Determining whether any pair of segments intersects
Segment-intersection pseudocode
Convex Hull

More Related Content

Similar to Unit-5 BSR-1-02-2024 advanced algorithms .pptx

Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphicsShaishavShah8
 
Clipping & Rasterization
Clipping & RasterizationClipping & Rasterization
Clipping & RasterizationAhmed Daoud
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmKasun Ranga Wijeweera
 
An Algorithm to Find the Visible Region of a Polygon
An Algorithm to Find the Visible Region of a PolygonAn Algorithm to Find the Visible Region of a Polygon
An Algorithm to Find the Visible Region of a PolygonKasun Ranga Wijeweera
 
machine learning.pptx
machine learning.pptxmachine learning.pptx
machine learning.pptxAbdusSadik
 
Computer graphics notes 2 tutorials duniya
Computer graphics notes 2   tutorials duniyaComputer graphics notes 2   tutorials duniya
Computer graphics notes 2 tutorials duniyaTutorialsDuniya.com
 
Dimension Reduction Introduction & PCA.pptx
Dimension Reduction Introduction & PCA.pptxDimension Reduction Introduction & PCA.pptx
Dimension Reduction Introduction & PCA.pptxRohanBorgalli
 
The Catholic University of America School of Engineering .docx
The Catholic University of America School of Engineering .docxThe Catholic University of America School of Engineering .docx
The Catholic University of America School of Engineering .docxmattinsonjanel
 
Bt9301, computer graphics
Bt9301, computer graphicsBt9301, computer graphics
Bt9301, computer graphicssmumbahelp
 
Lec02 03 rasterization
Lec02 03 rasterizationLec02 03 rasterization
Lec02 03 rasterizationMaaz Rizwan
 
Lec02 03 rasterization
Lec02 03 rasterizationLec02 03 rasterization
Lec02 03 rasterizationMaaz Rizwan
 
scan conversion of point , line and circle
scan conversion of point , line and circlescan conversion of point , line and circle
scan conversion of point , line and circleDivy Kumar Gupta
 
Cs8092 computer graphics and multimedia unit 3
Cs8092 computer graphics and multimedia unit 3Cs8092 computer graphics and multimedia unit 3
Cs8092 computer graphics and multimedia unit 3SIMONTHOMAS S
 

Similar to Unit-5 BSR-1-02-2024 advanced algorithms .pptx (20)

Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
Clipping & Rasterization
Clipping & RasterizationClipping & Rasterization
Clipping & Rasterization
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing Algorithm
 
MATLABgraphPlotting.pptx
MATLABgraphPlotting.pptxMATLABgraphPlotting.pptx
MATLABgraphPlotting.pptx
 
An Algorithm to Find the Visible Region of a Polygon
An Algorithm to Find the Visible Region of a PolygonAn Algorithm to Find the Visible Region of a Polygon
An Algorithm to Find the Visible Region of a Polygon
 
machine learning.pptx
machine learning.pptxmachine learning.pptx
machine learning.pptx
 
Brute force
Brute forceBrute force
Brute force
 
Clipping
ClippingClipping
Clipping
 
Computer graphics notes 2 tutorials duniya
Computer graphics notes 2   tutorials duniyaComputer graphics notes 2   tutorials duniya
Computer graphics notes 2 tutorials duniya
 
Unit 4 notes
Unit 4 notesUnit 4 notes
Unit 4 notes
 
Dimension Reduction Introduction & PCA.pptx
Dimension Reduction Introduction & PCA.pptxDimension Reduction Introduction & PCA.pptx
Dimension Reduction Introduction & PCA.pptx
 
Curve Fitting
Curve FittingCurve Fitting
Curve Fitting
 
The Catholic University of America School of Engineering .docx
The Catholic University of America School of Engineering .docxThe Catholic University of America School of Engineering .docx
The Catholic University of America School of Engineering .docx
 
5th Unit CAD.pdf
5th Unit CAD.pdf5th Unit CAD.pdf
5th Unit CAD.pdf
 
Bt9301, computer graphics
Bt9301, computer graphicsBt9301, computer graphics
Bt9301, computer graphics
 
Lec02 03 rasterization
Lec02 03 rasterizationLec02 03 rasterization
Lec02 03 rasterization
 
Lec02 03 rasterization
Lec02 03 rasterizationLec02 03 rasterization
Lec02 03 rasterization
 
scan conversion of point , line and circle
scan conversion of point , line and circlescan conversion of point , line and circle
scan conversion of point , line and circle
 
Cs8092 computer graphics and multimedia unit 3
Cs8092 computer graphics and multimedia unit 3Cs8092 computer graphics and multimedia unit 3
Cs8092 computer graphics and multimedia unit 3
 
Boundary fill algm
Boundary fill algmBoundary fill algm
Boundary fill algm
 

More from IronMan665214

Unit-4-BSR-11-1-2024 (1)linear programming.pptx
Unit-4-BSR-11-1-2024 (1)linear programming.pptxUnit-4-BSR-11-1-2024 (1)linear programming.pptx
Unit-4-BSR-11-1-2024 (1)linear programming.pptxIronMan665214
 
Unit-5-BasicProcessing_Parallel-26-1-2023-5am.pptx
Unit-5-BasicProcessing_Parallel-26-1-2023-5am.pptxUnit-5-BasicProcessing_Parallel-26-1-2023-5am.pptx
Unit-5-BasicProcessing_Parallel-26-1-2023-5am.pptxIronMan665214
 
UHV_IntroductionClass-11-6-2023-7am.pptx
UHV_IntroductionClass-11-6-2023-7am.pptxUHV_IntroductionClass-11-6-2023-7am.pptx
UHV_IntroductionClass-11-6-2023-7am.pptxIronMan665214
 
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.pptUnit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.pptIronMan665214
 
2_Effects of Human activities.pptx
2_Effects of Human activities.pptx2_Effects of Human activities.pptx
2_Effects of Human activities.pptxIronMan665214
 
Unit1_Basic_Structure_of_Computer-7-11-2022-11am.ppt.pdf
Unit1_Basic_Structure_of_Computer-7-11-2022-11am.ppt.pdfUnit1_Basic_Structure_of_Computer-7-11-2022-11am.ppt.pdf
Unit1_Basic_Structure_of_Computer-7-11-2022-11am.ppt.pdfIronMan665214
 

More from IronMan665214 (7)

Unit-4-BSR-11-1-2024 (1)linear programming.pptx
Unit-4-BSR-11-1-2024 (1)linear programming.pptxUnit-4-BSR-11-1-2024 (1)linear programming.pptx
Unit-4-BSR-11-1-2024 (1)linear programming.pptx
 
Dev AAT.pptx
Dev AAT.pptxDev AAT.pptx
Dev AAT.pptx
 
Unit-5-BasicProcessing_Parallel-26-1-2023-5am.pptx
Unit-5-BasicProcessing_Parallel-26-1-2023-5am.pptxUnit-5-BasicProcessing_Parallel-26-1-2023-5am.pptx
Unit-5-BasicProcessing_Parallel-26-1-2023-5am.pptx
 
UHV_IntroductionClass-11-6-2023-7am.pptx
UHV_IntroductionClass-11-6-2023-7am.pptxUHV_IntroductionClass-11-6-2023-7am.pptx
UHV_IntroductionClass-11-6-2023-7am.pptx
 
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.pptUnit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
 
2_Effects of Human activities.pptx
2_Effects of Human activities.pptx2_Effects of Human activities.pptx
2_Effects of Human activities.pptx
 
Unit1_Basic_Structure_of_Computer-7-11-2022-11am.ppt.pdf
Unit1_Basic_Structure_of_Computer-7-11-2022-11am.ppt.pdfUnit1_Basic_Structure_of_Computer-7-11-2022-11am.ppt.pdf
Unit1_Basic_Structure_of_Computer-7-11-2022-11am.ppt.pdf
 

Recently uploaded

Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 

Recently uploaded (20)

Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 

Unit-5 BSR-1-02-2024 advanced algorithms .pptx

  • 2. Computational Geometry • Computational geometry is the branch of computer science that studies algorithms for solving geometric problems. • In modern engineering and mathematics, computational geometry has applications in such diverse fields as computer graphics, Robotics, VLSI design, Computer-Aided Design, Molecular Modeling, Metallurgy, Manufacturing, Textile Layout, Forestry, and Statistics. • The input to a computational geometry problem is typically a description of a set of geometric objects represented as a set of points {pi}, where each pi = (xi, yi) and xi, yi є R. For example, an n-vertex polygon P is represented by a sequence {p0, p1, p2, . . . , pn-1} of its vertices in order of their appearance on the boundary of P. • The output is often a response to a query about the objects, such as  Whether one segment is clockwise or counter clockwise from another?  Which way should we turn when traversing two adjoining line segments?  Whether two line segments intersect?
  • 3. Computational Geometry • In this unit, we look at a few computational-geometry algorithms in two dimensions, that is, in the plane. • Computational geometry can also apply to three dimensions, and even higher-dimensional spaces, but such problems and their solutions can be very difficult to visualize
  • 4. Computational Geometry Line-segment properties we shall explore the following questions: There are no restrictions on the given points. We can answer each question in O(1) time. Moreover, our methods use only additions, subtractions, multiplications, and comparisons. We need neither division nor trigonometric functions, both of which can be computationally expensive.
  • 5. Cross products • Computing cross products is at the heart of line-segment methods. • Consider vectors p1 and p2, shown in figure. • The cross product p1X p2 can be interpreted as the signed area of the parallelogram formed by the points (0, 0), p1, p2, and p1 + p2 = (x1 + x2, y1 +y2).
  • 6. Cross products • An equivalent, but more useful, definition gives the cross product as the determinant of a matrix.
  • 8. Cross Products Question 1 Determine whether a directed segment is in a clockwise direction or in a counterclockwise direction to with respect to their common endpoint p0. Solution 1. Map p0 to (0,0), p1 to p1’, p2 to p2’ p1’ = p1 – p0 , and p2’ = p2 –p0 Similarly p2’ Then compute the cross product
  • 10. Cross Products Question 3 Determining whether two line segments intersect • To determine whether two line segments intersect, we check whether each segment straddles the line containing the other. • A segment straddles a line if point p1 lies on one side of the line and point p2 lies on the other side. • Two line segments intersect if and only if either (or both) of the following conditions holds: 1. Each segment straddles the line containing the other. 2. An endpoint of one segment lies on the other segment. (This condition comes from the boundary case.
  • 11. Cross products Question 3 Determining whether two line segments intersect
  • 12. Determining whether any pair of segments intersects • Algorithm to determine whether any two line segments in a set of segments intersect or not using a technique known as “Sweeping”. • The algorithm runs in O(n log n) time, where n is the number of segments. It determines whether any two line segments in a set of segments intersect or not. • It takes (n2) time in the worst case to find all the intersections in a set of n line segments. • In sweeping, an imaginary vertical sweep line passes through the given set of geometric objects, usually from left to right. • We treat the spatial dimension that the sweep line moves across, in this case the x-dimension, as a dimension of time. • The line-segment-intersection algorithm considers all the line-segment endpoints in left-to- right order and checks for an intersection each time it encounters an endpoint.
  • 13. Determining whether any pair of segments intersects • To describe and prove correct the line-segment-intersection algorithm for determining whether any two of n line segments intersect or not, we shall make two simplifying assumptions.  First, we assume that no input segment is vertical.  Second, we assume that no three input segments intersect at a single point.
  • 14. Determining whether any pair of segments intersects Ordering segments • Because we assume that there are no vertical segments, we know that any input segment intersecting a given vertical sweep line intersects it at a single point. • Thus, we can order the segments that intersect a vertical sweep line according to the y- coordinates of the points of intersection. • To be more precise, consider two segments s1 and s2. We say that these segments are comparable at x if the vertical sweep line with x-coordinate x intersects both of them.
  • 15. Determining whether any pair of segments intersects Ordering segments
  • 16. Determining whether any pair of segments intersects Moving the sweep line Sweeping algorithms typically manage two sets of data: 1. The sweep-line status gives the relationships among the objects that the sweep line intersects. 2. The event-point schedule is a sequence of points, called event points, which we order from left to right according to their x-coordinates. As the sweep progresses from left to right, whenever the sweep line reaches the x-coordinate of an event point, the sweep halts, processes the event point, and then resumes. 3. Changes to the sweep-line status occur only at event points. If the input contains n segments, we can perform each of the operations INSERT, DELETE, ABOVE, and BELOW in O(lg n) time using red-black trees.
  • 17. Determining whether any pair of segments intersects Segment-intersection pseudocode The following algorithm takes as input a set S of n line segments, returning the boolean value TRUE if any pair of segments in S intersects, and FALSE otherwise. A red-black tree maintains the total preorder T .
  • 18. Determining whether any pair of segments intersects Segment-intersection pseudocode