Clockwise or Counterclockwise - MATLAB Cody - MATLAB Central

Problem 194. Clockwise or Counterclockwise

Difficulty:Rate

Given a list of 2-d points defining the vertices of a polygon, determine whether these points are sorted clockwise.

The inputs to this function are two vectors x and y (with equal size) containing the x- and y- coordinates of the polygon vertices, respectively.

The function should return true when sorted clockwise, and false when sorted counterclockwise (the polygon vertices will always be sorted either way).

Example:

x = [-1,-1,1,1];
y = [-1,1,1,-1];

defines a square, the vertices are listed clockwise

d_correct = true;

Solution Stats

22.6% Correct | 77.4% Incorrect
Last Solution submitted on May 31, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
2
3

Problem Recent Solvers209

Suggested Problems

More from this Author38

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!