The polar angle of a point p 1 with respect to an origin point p 0 is

Question:

The polar angle of a point p1 with respect to an origin point p0 is the angle of the vector p1 − p0 in the usual polar coordinate system. For example, the polar angle of (3, 5) with respect to (2, 4) is the angle of the vector (1, 1), which is 45 degrees or π/4 radians. The polar angle of (3, 3) with respect to (2, 4) is the angle of the vector (1, − 1), which is 315 degrees or 7π/4 radians. Write pseudocode to sort a sequence 〈p1, p2, . . . ,pn〉 of n points according to their polar angles with respect to a given origin point p0. Your procedure should take O(n lg n) time and use cross products to compare angles.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question

Introduction to Algorithms

ISBN: 978-0262033848

3rd edition

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

Question Posted: