function for generate random line

Hello everybody!

I need a function that generates a random polyline (matrix with two columns - x and y).
The step length and rotation is determined (from the previous direction) randomly
based on a uniform distribution. The range of length and rotation values,
as well as the number of steps are function parameters.

Thanks a lot!

What have you tried so far? what is your specific problem?, we are more inclined towards helping you with specific coding problems rather than doing your work for you.

I wrote function which generate polyline, but idk how determine step length and rotation

myfun = function(n){
x=1:n
y=cumsum(rnorm(n))
data = data.frame(x,y)
plot(data,type='l')
}

What would an answer to your question look like?

I solved the task myself. Thanks for help

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.