ray casting problem
4 ビュー (過去 30 日間)
古いコメントを表示
Dear all I have a ray casting problem, I must perform raycasting in a local sphere S at a voxel x , but I don't know how to increment d or t in this formule, p = t d + p0 can any one give me a complete code please? thanks in advance
回答 (10 件)
Grzegorz Knor
2011 年 9 月 2 日
Are you familiar with this file?
1 件のコメント
Grzegorz Knor
2011 年 9 月 2 日
BTW:
http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
Bere
2011 年 9 月 3 日
1 件のコメント
Walter Roberson
2011 年 9 月 3 日
Your first step is to figure out how to do a uniform random distribution over a sphere. It is easy to get that step wrong. I suggest you search the Newsgroup for back postings by Roger Stafford as he has posted the algorithm a few times.
What do you want to *do* with the rays when they stop? If your answer is "draw them", then be advised that you are going to have difficulty representing a uniform random 3-space distribution to a fundamentally pixelized display.
What is your representation of the local structures?
Bere
2011 年 9 月 6 日
1 件のコメント
Walter Roberson
2011 年 9 月 6 日
Which formula are you using for the uniform random distribution over the sphere?
What is your representation of the local structures whose presence must be detected?
Bere
2011 年 9 月 6 日
1 件のコメント
Walter Roberson
2011 年 9 月 6 日
If you do not have a formula for the uniform distribution over the sphere, then you have *not* done the research I suggested in to Roger Stafford's postings on the subject.
When you do not do your part in working on *your* question, it leaves people uninterested in helping you.
Read this:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/150991
Perhaps someone else will clarify the difference between what an object _is_ and how you _represent_ the object.
Bere
2011 年 9 月 14 日
1 件のコメント
Walter Roberson
2011 年 9 月 14 日
Now you need to tell us about the representation of the various objects you have. What data structure do you use to hold the information about them.
For example, the tube: you must have some kind of mathematical model of it, or some kind of approximation of the surface of it. If I were to specify a particular coordinate (x1,y1,z1) then how would it be possible to tell whether that coordinate was inside the tube, at the surface of the tube, or outside the tube?
If a point were determined to be at the surface of the tube, then how would it be possible to tell what the normal is at that point, so that the angle of reflection can be determined?
Is the tube made out of glass? With uniform thickness? With uniform coloration? Is it transparent or translucent or completely opaque? If it is transparent or translucent then how do you represent the index of refraction so that it would be possible to model the bending of light by the tube?
The tube junction: with the information you have given so far, we might guess that the tube is made out of glass or plastic, but if so then it is very unlikely to be a constant thickness all through the junction; and especially if it is glass, chances are strong that it has different indices of refraction at different points on the surface and as you go in to the object. How is the information about that represented?
Bere
2011 年 9 月 14 日
3 件のコメント
Walter Roberson
2011 年 9 月 14 日
What are I(p) and I(x), and e ? And is your formula perhaps incorrect? You have I(x)/I(x) which would simplify to 1 when I(x) is non-zero.
For a given (x0,y0,z0) point, how do we determine I(p) and I(x) ? As you do not mention y or z, is the implication that I is independent of y and z?
Are you perhaps trying to indicate that what you have is a 3D array of intensities and you want to do the ray tracing with respect to that intensity array? That you do not have a mathematical model of the tube and so on, just an array of intensities?
Bere
2011 年 9 月 14 日
3 件のコメント
Walter Roberson
2011 年 9 月 14 日
Ah, I did not notice before that you are doing local ray casting from a number of different points, and I had not realized before the significance of the surface of the sphere.
I take it that R(x) is the radius (shouldn't that be R(p) if p is your current central voxel?) Does F(x) have any significance to the ray casting, or is it just "something that is needed to calculate the radius" as far as the ray casting goes?
Having the voxels not be equal length in each dimension adds some challenge, but should be workable.
This might be easier (faster) if no linear interpolation is done.
Oh my... potentially up to 27 voxels involved in a single interpolation. This I'm going to have to think on more carefully.
Bere
2011 年 9 月 15 日
2 件のコメント
Walter Roberson
2011 年 9 月 15 日
Consider a point right at the center of a 3x3x3 cube. You might perhaps define the value for that point to be the value associated with the center voxel, a single value.
Now move the point. As it approaches the outside of the center voxel, your need for linear interpolation requires that the values of adjacent voxels be taken in to account in proportion to the distance of the point to the center of that voxel.
Suppose the point were to be moved to an exact vertex of the central voxel. Should only the voxels along the 3 axes (up/down, left/right, front/back) together with the center be taken in to account for the interpolation? Logically, No: at the vertex, the distance to the center of the center voxel is the same as the distance to the center of voxel that the diagonal continuation of the direction of the center towards the point, so if the contribution relative to distance is what is taken in to account, the diagonal needs to be weighted the same as the center.
Likewise as you move around near the edges of the central voxel at other locations (e.g., near one of the edges), you clearly need to take in to account the voxels in some of the other directions including diagonals on other planes.
As the cube is 3x3x3, that is up to 27 different voxels that might be involved in the calculation.
What is the maximum number of voxels that need to be considered for any one of the calculations? Well, you might have *defined* the value at the very center of the central voxel to be the same as the value of the center voxel, but as soon as you "wiggle" the point position even a little off of the center, that definition cannot hold for a linear interpolation, so the the number is going to depend on exactly how you define your linear interpolation. If you cull the voxels according to which half-planes the point under consideration is in, because the point might have only wiggled on one of the three axes, you might only cull a single 3x3 face, leaving 18 voxels to take in to account. Even then it is hard to justify culling a voxel that is distance 1/2 + epsilon away while still justifying using the contribution of the central voxel at distances further than 1/2 away from the center (i.e., beyond the outside of the maximum sphere that could be inscribed in the cube). Culling by half-plane becomes even more suspect when you take in to account that your voxels are not actually cubes.
Linear interpolation is based upon contribution of value proportional to distances, and on a simple straight line does ignore the value on "the other side", but I need to think more on how to mathematically formulate that cutoff in a manner that is fair for cuboids. Or, I suppose, I could just use interpn() and hope that it takes care of the details fairly.
Perhaps linear interpolation should not be used if the point falls within the inscribed sphere? Note that the inscribed sphere would have the radius equal to the smallest voxel dimension, not touching the walls along the larger dimension.
Fareena
2017 年 3 月 8 日
Dear Bere
Did you solve this? If yes; please provide me with the code.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Biomechanics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!