Randomly oriented two sided ball roll
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Alan Hanley
am 19 Mai 2016
Kommentiert: John D'Errico
am 19 Mai 2016
I need ideas for developing a model that rolls two sided balls onto a flat surface. Essentially, if one side is red and the other blue, and i rolled 1000 of them onto a surface, I need to know what portion of the red and blue sides are visible from an aerial view (two-dimensional view directly above the flat surface). I have limited experience with Matlab and am not sure where to start. Any thoughts would be appreciated!
0 Kommentare
Akzeptierte Antwort
John D'Errico
am 19 Mai 2016
Bearbeitet: John D'Errico
am 19 Mai 2016
This is not a MATLAB question. It is a simple question of mathematics.
Viewed from a fixed point of view, a sphere is just a circle. Some fraction of the area will be red, some blue. That is just a formula based on the rotation of the sphere. (Do the MATH! Again, NO MATLAB content there though, unless you don't know how to write a function. In that case, you need to read the basic tutorials.)
I'll give you a hint there: Viewed from an angle, a great circle of a sphere appears to be an ellipse. Can you compute the parameters of that ellipse as a function of rotation angle? If you know the ellipse parameters, then computing the area of an ellipse is trivial. And if you can compute the area of that ellipse, computing the red/blue fractional area seen is also trivial.
So next, once you know the fraction of the circular area that will be seen as red as a function of the orientation of the sphere, now it is a question of computing the distribution of red fraction, again based on orientation. That is just a case of random sampling. So compute 1000 random angles, then evaluate your formula and compute the mean, plot a histogram, whatever. Even better would be to use techniques of statistical tolerancing to compute that distribution. Whatever makes you happy there.
Note that you can reduce the red fraction seen to a problem in ONE rotation angle. This is not a problem with two or more degrees of freedom. (Think about it. Think about symmetry.)
1 Kommentar
John D'Errico
am 19 Mai 2016
More in depth hint:
consider the unit sphere
x^2 + y^2 + z^2 = 1
A great circle of that sphere can be written as the intersection of the sphere with the plane z=0. Now, lets rotate that plane through an angle u, around the x axis. This reduces to a transformation of the problem using simple rotational geometry. so something like
A = [1 0 0;0 cos(u) sin(u);0 -sin(u) cos(u)];
So, if we multiply the matrix A with the vector [x;y;z], we can find the necessary intersection. It reduces to
-sin(u)*y + cos(u)*z = 0
or
z = y*tan(u)
If we find the intersection of that rotated plane with the sphere, essentially projected into the z=0 plane, we get
x^2 + y^2*(1 + tan(u)^2) = 1
So, as a function of rotation angle u, the great circle appears to be an ellipse. We can compute the area of that ellipse simply enough, as
area_ellipse = pi/(1+tan(u)^2)
Assume the top of the sphere is blue, the bottom red. What fraction of the circular region is blue? Divide by the area of the circle, so pi, to get a fractional area. Next, recognize that we see only one half of a great circle when a sphere is rotated, only the portion on top. So the red fraction seen will be something like
(1 - 1/(1+tan(u)^2))/2
If u is represented in degrees, we need
(1 - 1/(1+tand(u)^2))/2
So as u goes rom 0 to 90 degrees, that red fraction goes from 0 to 0.5.
So, for example, if the rotation angle is given by u, when u == 0, the red fraction seen is 0. The entire sphere seen is blue. At 90 degrees, the sphere is 50% red, 50% blue.
Of course, that formula fails to work above 90 degrees, but it is repairable.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!