Problem 60311. Travel a path
In Cody Problem 60251, minnolina asks us to determine the end point given a string indicating unit movements forward, backward, left, and right. For example, ‘fflff’ brings the marker to the point (-1,4).
This problem extends that one by specifying a heading (H)—i.e., an angle in degrees measured clockwise from north, or the positive y-direction—and a distance (D) to move. The movement string corresponding to the example above would be ‘H0 D1 H0 D1 H270 D1 H0 D1 H0 D1’.
Write a function that determines the points, starting at an initial point with coordinates in x0y0, resulting from a movement string. The output should be an nx2 matrix with the x and y coordinates of the points in the columns.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers4
Suggested Problems
-
Find relatively common elements in matrix rows
2051 Solvers
-
What is the distance from point P(x,y) to the line Ax + By + C = 0?
372 Solvers
-
Find Index of maximum Value and maximum Value of a vector
165 Solvers
-
Kryptos - CIA Cypher Sculpture: Vigenere Encryption
53 Solvers
-
Create a matrix with difference of each row of input matrix
74 Solvers
More from this Author279
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!