Random Gaussian Surface Generation

66 visualizaciones (últimos 30 días)
Michelle Conner
Michelle Conner el 26 de Mayo de 2015
Comentada: Shreedhar Savant Todkar el 18 de Dic. de 2020
I am working on designing a Random Gaussian Surface that I would then be able to take to a 3D printer and print the surface to use in the project I have been working.
I thought Matlab would hopefully be the easiest method in completing this task.
I have been doing research on the Random Gaussian Surface and happened upon this http://www.mysimlabs.com/surface_generation.html
About half way down the page there is two function files (rsgene1D and rsgene2D). Using these function files the creator of that site is able to produce the two images.
The image on the left being the 1D and the image on the right being the 2D. The only thing that is not included on the page is the Script file in creating these graphs.
I have been working on trying to figure out what my script file should be. But haven't been able to have any luck. Getting the 2D image on the right. Or something similar.
So this is where I ask for your help. I have placed the function file that came from the website and my script file I have created. What I am hoping is that someone can help me in determine of what it is that I am missing in my file. (Before I go to try to contact that guy who created the file and website. The website itself doesnt seem to have been updated for around 3-4 years now. So that might be a last resort).
Or if unable to help with the files I have currently.
Help me in determination of a way to created a plot that would be similar to that on the right hand side of the above image. And also be able to be changed to different types of Gaussian surfaces.
Thank you in advance!
The two are the following codes that are being used. For whatever reason the function file will not go into its own coding box. So I have also attached a photo of the file in Matlab itself.
function [f,x,y] = rsgene2D(N,rL,h,clx,cly) % % [f,x,y] = rsgene2D(N,rL,h,clx,cly) % % generates a square 2-dimensional random rough surface f(x,y) with NxN % surface points. The surface has a Gaussian height distribution and % exponential autocovariance functions (in both x and y), where rL is the % length of the surface side, h is the RMS height and clx and cly are the % correlation lengths in x and y. Omitting cly makes the surface isotropic. % % Input: N - number of surface points (along square side) % rL - length of surface (along square side) % h - rms height % clx, (cly) - correlation lengths (in x and y) % % Output: f - surface heights % x - surface points % y - surface points % % Last updated: 2010-07-26 (David Bergström). %
format long;
x = linspace(-rL/2,rL/2,N); y = linspace(-rL/2,rL/2,N); [X,Y] = meshgrid(x,y);
Z = h.*randn(N,N); % uncorrelated Gaussian random rough surface distribution % with rms height h
% isotropic surface if nargin == 4 % Gaussian filter F = exp(-(abs(X)+abs(Y))/(clx/2));
% correlation of surface including convolution (faltung), inverse
% Fourier transform and normalizing prefactors
f = 2*rL/N/clx*ifft2(fft2(Z).*fft2(F));
% non-isotropic surface elseif nargin == 5 % Gaussian filter F = exp(-(abs(X)/(clx/2)+abs(Y)/(cly/2)));
% correlation of surface including convolution (faltung), inverse
% Fourier transform and normalizing prefactors
f = 2*rL/N/sqrt(clx*cly)*ifft2(fft2(Z).*fft2(F));
end
Then the following is the script file I have been working with. This includes both the 1D and 2D information. I have mostly gotten the 1D to work. But it is not exact. But similar.
The 2D is where I have been having the most issues.
clc, clear all, close all
N = 150;
rL = 10;
h = .14;
clx = .125;
cly = .125;
figure(1) %2D Plot
[f,x,y] = rsgene2D(N,rL,h,clx,cly);
plot3(f,x,y)
%figure(2) %1D Plot
%cl = .125;
%[f,x] = rsgene1D(N,rL,h,cl)
%plot(x,f)
Thank you in advance for any insight into my issues.
  3 comentarios
Elijah Uche
Elijah Uche el 15 de Sept. de 2020
Hi Michelle,
Please how do I obtain the underlying equations or maths on which this rough surface model was built?
This will help my understanding of it as well as help me fuly appreciate how it works.
Many thanks
Elijah
Shreedhar Savant Todkar
Shreedhar Savant Todkar el 18 de Dic. de 2020
Elijah,
Have you considered using
  1. HFSS
  2. gprMax
these are the ones I use to generate rough surfaces with specific parameters (permittivity, conductivity etc).
Good luck

Iniciar sesión para comentar.

Respuestas (2)

Alfonso Nieto-Castanon
Alfonso Nieto-Castanon el 26 de Mayo de 2015
Editada: Alfonso Nieto-Castanon el 27 de Mayo de 2015

You may use something like:

 N = [500 500]; % size in pixels of image
 F = 3;        % frequency-filter width
 [X,Y] = ndgrid(1:N(1),1:N(2));
 i = min(X-1,N(1)-X+1);
 j = min(Y-1,N(2)-Y+1);
 H = exp(-.5*(i.^2+j.^2)/F^2);
 Z = real(ifft2(H.*fft2(randn(N))));
 surf(X,Y,Z,'edgecolor','none');
 light;

(play with the N and F parameters to get the desired effect; you will also probably need to rescale the X/Y/Z variables to whatever scale is meaningful to your scanner)

Also you may want to check this Matlab blog for some tips on 3d-printing using Matlab

  1 comentario
rong yi
rong yi el 30 de Mayo de 2020
I used your script, and it worked well, but I have some questions.
In some articles, they used z = ifft2(fft2(randn(N)).*fft2(H)) to generate the surface, and they called H as autocorrelation function, and F as autocorrelation length.
So, in your script, can we also call H as autocorrelation function, and F as autocorrelation length ?
Thanks very much!

Iniciar sesión para comentar.


Mona Mahboob Kanafi
Mona Mahboob Kanafi el 19 de Dic. de 2016
Hei Michelle, although it is already late for you, but maybe this could help someone else. Now, you can easily use below code to generate a randomly rough isotropic surface:
I've been involved with the exact same research as you, and I developed this code to later 3D print my artificially generated surface topography. You can refer to below article for the results related to the replication efficacy of the 3D printer and the application of randomly rough 3D-printed substrates:
Kanafi, Mona Mahboob, and Ari Juhani Tuononen. "Application of three-dimensional printing to pavement texture effects on rubber friction." Road Materials and Pavement Design (2016): 1-17.
BR,
-Mona
  2 comentarios
Elijah Uche
Elijah Uche el 24 de Jun. de 2020
Hi Mona,
Please how do I introduce dielectric constants like permittivity, conductivity, conductivity etc... to my rough surface model?
I am currently working on developing a rough surface model for a soil surface which is affected by these dielectric constants.
Thanks
Elijah Uche
Elijah Uche el 15 de Sept. de 2020
Hi Mona,
Please I would like to be able to obtain the underlying equations and maths on which this rough surface model was built on so I could fully appreciate how it works

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by