-
2 Comments
any hints on how to reduce the size of this thing?
Hi Anton, here's a hint: You're chopping down P then taking the difference between itself and its circshift. This is very close to just a simple diff() command. Circshift is a useful function, but not quite where you've got it ;)
Think of it this way:
A diff() will get vectors from one point to the next. If any neighbouring vectors point in the exact same direction, they are fair game to remove. More specifically, whenever the direction of the line *changes*, you've found a vertex you want to keep. How can you detect that?
Suggested Problems
-
4515 Solvers
-
Project Euler: Problem 5, Smallest multiple
1505 Solvers
-
Back to basics 17 - white space
272 Solvers
-
We love vectorized solutions. Problem 1 : remove the row average.
832 Solvers
-
Determine the number of odd integers in a vector
755 Solvers
More from this Author5
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!