Download COMPUTATIONAL GEOMETRY

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
COMPUTATIONAL
GEOMETRY AND MATRIX
MULTIPLICATION
Mohammed Zeeshan Farooqui
Minhaj Uddin
CSE@UTA
COMPUTATIONAL GEOMETRY



Data is defined as points, lines, surfaces, polygons
etc.
Convex
Non-convex
Convex Polygon has every in degree less than 180
Non Convex Polygon may have one or more in
degrees greater than 180
CSE@UTA
Computational Geometry – Position of Point
 Problem: To determine whether a given point lies
outside or inside a given polygon.
 Answer: Yes if the point lies inside the polygon, No
otherwise
 Solution: Draw a line along the X –axis from the point
in one direction i.e. the line can have a increasing as
well as decreasing X – axis.
 If the line thus drawn intersects ONLY once with any
edge of the polygon then the point lies inside the
polygon else it lies outside the polygon
CSE@UTA
Computational Geometry – Position of Point (..contd.)

Example:
_ _ _ _ _ _ _ _ _ __ _ _.P
The above point intersects only once with an edge of the polygon hence it lies inside
polygon
CSE@UTA
Computational Geometry – Position of Point (…contd)

Example:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .P
(a)
____ __
__
_ _.P
(b)
(a) The line extending from point P intersects the polygon edges more than once (twice in this
Example), hence P lies outside the polygon
(b) In case of Non Convex Polygon, a given point lies inside the polygon if the line segment
Extending from it intersects the polygon edges an ODD number of times else it lies outside
CSE@UTA
Convex Hulls


Informally,Convex hull is defined as an Convex
Polygon whose vertices come from the original points
and its perimeter encapsulates all the points.
Definition:The Convex Hull of a set Q of points is the
smallest convex polygon P, for which each point in Q
is either on the boundary of P or in its interior.
If there is a plane Q , consisting of nails sticking out
from a board. Then the Convex Hull of Q can be
thought of the shape formed by a tight rubber band
that surrounds all the nails
CSE@UTA
Convex Hulls

Example of an Convex Hull
P10
P7
P9
P6
P5
P3
P11
P8
P12
P4
P2
P1
Po
CSE@UTA
Convex Hull – Jarvis March



Convex Hull
Jarvis March
Graham Scan
Jarvis March: Computation of Convex Hull
 For Every Point, join with all the original points and
for the resulting line segments compute the angle
with respect to origin, the smallest angle thus
obtained gives the next point.
2
 Running time is O(n )
 Actual running time is O(n*h), where h is the number
of points on the convex hull.
CSE@UTA
Convex Hull – Jarvis March (…contd.)

Jarvis March’s algorithm
starts from P0 ie the
anchor point.
Example of Jarvis March
P8
P6
P9
P7
P5
P3
P2
P0
P4
P1
Then it wraps the next
outer point and makes
this as the new anchor
point and repeats the
procedure for the rest of
the points…….
Till every point is
wrapped inside.
CSE@UTA
Convex Hull – Graham Scan





Graham Scan – Computation of Convex Hull
Sort angles in counter clock wise direction
Create Polygon by connecting points in sorted order
Thereby a Non Convex Polygon results( Could also be
convex)
Now wrap the above Non – Convex polygon by a
convex polygon.
CSE@UTA
Convex Hull – Graham Scan (…contd.)





Algorithm (Package Wrapping or Gift Wrapping)
Start from bottom i.e. left most point going counter clockwise
Join with the next point in the counter clock wise direction so
long as the resulting line segment makes left turns (>180) it will
be included.
If the line segment forms an angle <180, then discard current
path, walk back to the previous points and join successfully with
new points and measure the resulting angle.
Running time is O(nlogn), as walking around takes 2n, since
each is traversed only twice in the worst case and once the
edge is dropped it is never again considered and the sorting of
angles takes O(logn), hence the resulting running time is
O(nlongn)
CSE@UTA
Convex Hull – Graham Scan (…contd.)

As shown, Grahams
starts from a point
(p0) and calculates
all the angles it
makes to all the
points and sorts the
angles in an order
CSE@UTA
Convex Hull – Graham Scan (…contd.)


It selects the point
with the least angle
and starts traversing
(P0-P1).
Then P1 to P2 &
from P2 to P3 it
realizes that it takes
a right turn, so it
backtracks and
selects P1 – P3
directly, it being
shorter
CSE@UTA
Convex Hull – Graham Scan (…contd.)

The algorithm
continues, based on
the above mentioned
conditions till it
reaches back to the
initial point. Hence
forming the Convex
Hull as shown:
CSE@UTA
Convex Hull – Graham Scan (…contd.)
CSE@UTA
Convex Hull – Graham Scan (…contd.)
CSE@UTA
Convex Hull – Graham Scan (…contd.)

Once the initial point
is reached the
algorithm self
terminates, and the
Convex Hull is
formed.
CSE@UTA
Multiplication of Large Numbers

Matrix Multiplication:
Traditional method Takes O(n2) time
Traditional Method
Given two matrices A and B compute their product.
A

B




CSE@UTA
Multiplication of Large Numbers (…contd.)

Divide the two arrays into two parts each, A into Al
and Ar, and B into Bl and Br.

Al
Ar

Bl
Br
CSE@UTA
Multiplication of Large Numbers (…contd.)


A = Al10n/2 + Ar
B = Bl10n/2 + Br
A.B = (Al10n/2 + Ar)( Bl10n/2 + Br)
= AlBl10n + AlBr10n/2 + ArBl10n/2 + ArBr
Time Complexity : T(n)
T(n) = 4T(n/2) + O(n)
= O(n2)
CSE@UTA
Multiplication of Large Numbers (…contd.)


The goal is to reduce the time complexity from O(n2).
The intuition is that since we use recursion in our
multiplication of the equation, if we can reduce the
number of calls to the recursive function Multiply(x,y)
the overall complexity of the problem can be
significantly reduced.
CSE@UTA
Multiplication of Large Numbers (…contd.)








Consider the equation from the previous slide:
AlBl10n + AlBr10n/2 + ArBl10n/2 + ArBr
This equation can be re-arranged as under:
AlBl10n/2 + (AlBr + ArBl)10n/2 + ArBr
Now, we call the multiplication function Mult(X,Y)
recursively as follows:
X = Mult(Al,Bl)
Y = Mult(Ar,Br)
P = Al + Ar
Q = Bl + Br
CSE@UTA
Multiplication of Large Numbers (…contd.)






Z = Mult(p,q)
U=Z–X–Y
Return: X10n + U10n/2 + Y, Where
X10n = AlBl10n/2
U10n/2 = (AlBr + ArBl)10n/2
Y = ArBr
Thus, in this approach we have replaced four calls to
the Mult(X,Y) function in the traditional method to
three calls.
CSE@UTA
Multiplication of Large Numbers (…contd.)
Thus the resulting time complexity is:
T(n) = 3T(n/2) + O(n)
= 3[3T(n/22) + n/2] + n
= 32T(n/22) + 3n/2 + n
= nlog23 = n1.7
Related documents