Hi everyone,
I need to define a rock shape like 3D Object. The dimensions and inputs types are not important. To sum up, I have to a rock shape in graph like the picture below. Thank you!

1 Comment

See the example file in the craters file exchange submission.

Sign in to comment.

 Accepted Answer

% My Rock
x = randn(1000,1);
y = randn(1000,1);
z = randn(1000,1);
% Alpha Shape and plot
as = alphaShape(x,y,z,4);
plot(as,'FaceColor',[218 136 86]./255,'EdgeAlpha',0)
title('My Rock')
lighting gouraud
light('Position',[2 -4 2],'Style','local')
A little pointy, but hey, I'm from New England and granite is pointy!!

11 Comments

John D'Errico
John D'Errico on 24 Dec 2014
Edited: John D'Errico on 24 Dec 2014
I could not resist making a "point"less response...
HAPPY HOLIDAYS!
Perhaps more to the "point"...
While I like your starting idea to use an alpha shape of a randn sample, you could then erode it a bit. How about deleting those simplexes on the surface with sharp interior surface angles?
Fistly, thank you for your answer! This is exactly what I want. But in my Matlab the alphaShape function does not work. I think I do not have alphaShape function in my Matlab Function Library. Thank you.
Alpha shapes were only released very recently as a tool in MATLAB. But they are in MATLAB itself, you do not need any toolboxes. So if you have a current copy of MATLAB, you will have alpha shapes.
Note that packing these alpha shapes together will get quite intensive.
Oooh, angles of the surface simplexes is a good idea; I was originally thinking of converting it to a binary volume and using an opening with a roundish structuring element. But just bisecting those polyhedra would probably work well and save the conversion to and from a volume.
And, thanks John; Happy Holidays to you too!! Are you going to sneak in some Bridge time?
(They're kicking us MathWorkers out at 1 today!)
Both of my face-to-face bridge partners are unavailable due to the holidays. Surely they should realize that bridge is a high priority compared to seeing their families? However, one nice thing about bridge is it can be played online.
I may take the opportunity to do so this week, and I need to do some more bridge writing, though I need to find a new place to post some more hands online.
I get this problem, and did not found a solution that..
So then you have too old of a MATLAB release.
It is Matlab R2013a version :/
alpha shapes were released in 2014. There are alpha shape tools on the file exchange though.
Ok I solved the problem with alphaShape, thank you!
Can you help me on, smoothing the edges of the rock?

Sign in to comment.

More Answers (1)

John D'Errico
John D'Errico on 24 Dec 2014
Edited: John D'Errico on 24 Dec 2014
The best material model of a cat is another, or preferably the same, cat.
Philosophy of Science (1945) (N. Wiener, A. Rosenblueth)
That observation would also apply to rocks.
You don't really say why you need a MATLAB rock. What are your goals for this rock? A model of a rock must have a purpose, otherwise one can clearly choose many ways to create said model. So, with no better information about your goals, I would start with a spherical rock. There is also a joke about spherical cows, in case you missed the reference, though spherical rocks may be a decent approximation for many problems. And since any model is an approximation, I don't know how good of a model you need.
Perhaps the picture was supposed to be a subtle hint. If so, then why not say what you will need it for? How good of a rock shape model do you need? For example, the picture shown shows vaguely irregular rocks, but not terribly so. But they also have cracks in them. A simple model of an irregular shape is easy enough. Go out into your yard, and pick up some rocks. Make careful measurements of said rock in 3-d. Input said data into MATLAB, then use an alpha shape to create a 3-d tessellation of said rock. Repeat with as many rocks as you can find. (When done with the rocks, drop them off in my yard, as I want some spare rocks for landscaping.) You might also use 3-d imaging to create very nice rocks. So it might help to know what you can use to build said rock models.
Do these "rocks" really need to be just simple things you can pack? Note that even sphere packing is not a trivial mathematical task. But you could start with a tessellation of a spherical rock, then add essentially fractal noise to the surface.
Or if you really need a rock model that includes cracks, dirt on the faces, etc., you need to do more work. (From my tenure as an ME, I recall that modeling crack propagation can be a difficult but interesting thing to do well.) So when you have a question, explain it. Explain your needs, your goals. And of course, it helps to know what your capabilities might be. Otherwise, we can do no better than go back to the quote I started with.

8 Comments

Sean de Wolski
Sean de Wolski on 24 Dec 2014
Edited: Sean de Wolski on 24 Dec 2014
In grad school, we took tomographic scans of our concrete samples at the APS at Argonne National Lab. Simple image processing then gave us the boundary and cracks in it.
This would actually work okay here, if the rocks could all not exceed about 1/3in diameter. And if you were willing to write a proposal to the US Department of Energy for beam time.
Hello, thank you John. You are right. I needed to be more clear. This problem is my final project for my civil engineering course. In picture, the grid is a geogrid(you can see the more detailed pictures about geogrid on Google). My projects aim is, to define random rocks and fit them into the geogrid's spacing like in picture. I did not need to visual detail on rock like cracks(but it can be good :)). The main purpose is to exact fit of the rocks in geogrid an get the visual like in the picture. I'm beginner user for Matlab and this project is so important for me. Any help will be greated thankfully! Thank you.
I agree with Sean and John that getting CT images of actual sand or gravel would be the most realistic. There are many universities and companies that have micro CT instruments that could do the scan for you at very high spatial resolution (much, much higher than you can get in a hospital where dosage limits the resolution they can achieve).
But if my assertion is reasonable, that rocks can be modeled as fractal surfaces, then it does not matter what size is the rock. It could be blown up to the desired scale with no problems.
Ok I got it. I will try to get cat pictures. Then, can you give me an idea about how to create a geogrid like in the picture in Matlab.
I thought the next question would end up being packing.
As I said before, even sphere packing can be non-trivial. The packing of general shapes into a tight complex is a very non-trivial thing to do. So, again, I really think you need to explain your final goals.
Why? Because for example, if in the end all you want is a pretty picture of some rocks, then find an artist who is willing to draw a picture of some rocks! Even easier, pile up some rocks, and take a picture of the pile.
However, if you need a complex of aggregated "rocks" for some other purpose, then what you need to tell us is the purpose of your project. What you will do with the result is crucial to knowing how to best build that result. And in the end, I would return you to that quote I started with. If you need a perfect model, then start with a pile of real rocks.
Ok John, you are right again. My project is about right placement of geogrids. Geogrid is a material that improve stability of the ground. In the ground, I will have randomly shaped rocks, and to have right placement for my geogrid, rocks should be exact fit in spacing. Because when we try to pull out geogrid, rocks must be prevent it. But if rocks don't fit in grid, then pulling out geogrids will be so easy and geogrids will become useless. To sum up, I will try to get best fitting positions of rocks in to geogrid.
So when I go a ground and take dimension of aggregas, then I can came up a fitting positions of it with this matlab codes. Then I can decide where should I place my geogrid.
Thank you for your help!

Sign in to comment.

Categories

Find more on Geology in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!