Create random paths between two known points in 3D

10 Ansichten (letzte 30 Tage)
Mauro Tramis
Mauro Tramis am 21 Mär. 2020
I'm trying to create a series of random paths between two known points and represent them on a 3d plot.
The goal is to start from a point with known coordinates and create different paths, randomly, in order to reach another point with known coordinates; after the creation of this random paths I need to represent them in a 3d plot using only one figure, in order to compare trajectories. I already found different solutions for the 2D case, but for converting them to 3D I'm stuck. Can anyone help me?
Thanks in advance
  4 Kommentare
Mauro Tramis
Mauro Tramis am 22 Mär. 2020
Your response was for a 2D case, not a 3D. I am not dealing with signals and noises, my goal is to obtain a trajectory between two known points (known coordinates) and the plots should be like they represent a motion (like in the picture below). The purpose to use different initial points is to observe the behaviour of all different trajectories
Image Analyst
Image Analyst am 22 Mär. 2020
My response was a demo for one signal, like x. You'd then apply that concept to y and z also to get all 3 coordinate vectors varying.
If you have vectors for x, y, and z for every purple curve, then why don't you just call rand() to add a tiny bit of noise to it and get the noisy path?

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Image Analyst
Image Analyst am 21 Mär. 2020
What I would do is to do something they do in the movie industry to create textures. It's called Perlin Noise. Google it. It's used to give very natural looking paths and surfaces, like mountains, clouds, water, stucco, wood, etc. Much more natural looking paths than the harsh, erratic paths you'd get simply by calling rand() and adding that noise to your signals.
Basically the way Perlin noise works is you take a very few locations (say 5) on your path (you can start with any existing path or even just a line along the x axis if you want) and add some noise to those few locations. Then you interpolate the other y to go through those locations. This gives you the large scale noise/deviations. Now you take another set of more locations, say 10. Then you add noise to those locations but the noise has lower amplitude than the prior iteration. Then interpolate again. Then just iterate a bunch of times decreasing the spacing between the noise points and decreasing their amplitude. So with each iteration you are adding finer and finer noise (smaller and more detailed). I wrote a demo for you that I think does that and I've attached the demo, perlin_noise.m. I also pin down the end points so that you start and end at the same locations, which is what you said you need. It produces plots such as the one below:
What you could do is use this to create 3 signals: one for x, one for y, and one for z. This will give a smoother, more natural path than if you just simply used rand() to add noise to your signals.
Adapt the code as needed, like build into a function, get rid of fancy plots, or whatever you need.
  2 Kommentare
Mauro Tramis
Mauro Tramis am 22 Mär. 2020
thanks for your answer, but i wrote wrongly the problem I needed to implement. I added a comment that describe the real problem
Mahmoud Elbeltagy
Mahmoud Elbeltagy am 7 Mär. 2021
wowww @Image Analyst very nice implementation!!
Thank you!

Melden Sie sich an, um zu kommentieren.


KSSV
KSSV am 21 Mär. 2020
A = [0,0,0] ;
B = [1,1,1] ;
N = 10 ;
x = (B(1)-A(1)).*rand(N) + A(1);
y = (B(2)-A(2)).*rand(N) + A(2);
z = (B(3)-A(3)).*rand(N) + A(3);
X = [A(1)*ones(N,1) x B(1)*ones(N,1)] ;
Y = [A(2)*ones(N,1) y B(2)*ones(N,1)] ;
Z = [A(3)*ones(N,1) z B(3)*ones(N,1)] ;
plot3(X',Y',Z')
  1 Kommentar
Mauro Tramis
Mauro Tramis am 22 Mär. 2020
thanks for your answer, but i wrote wrongly the problem I needed to implement. I added a comment that describe the real problem

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by