Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Student's problem about the implementation of custom implicit surface #109

Closed
Immocat opened this issue Aug 7, 2017 · 3 comments
Closed
Assignees
Labels

Comments

@Immocat
Copy link

Immocat commented Aug 7, 2017

Thanks for your code and book. I am a student learning fluid simulation, and I am a little confused about the implementation in custom_implicit_surface2(3).cpp

For instance, near line 125, function closestIntersectionLocal, file fluid-engine-dev/src/jet/custom_implicit_surface2.cpp:

double frac = fractionInsideSdf(prevPhi, newPhi);
double tSub = t + _resolution * frac;

result.isIntersecting = true;
result.distance = tSub;

As far as I know, the function "fractionInsideSdf" always returns a positive number in [0, 1]. Also, the "t" here gets "newPhi" SDF. So why "t" has to add a positive number " _resolution * frac" instead of minus?

Thanks for your attention to this matter.

@doyubkim
Copy link
Owner

doyubkim commented Aug 8, 2017

Hi @Immocat ! Thanks for your question. I think you found a bug in the code :)

   A                   B
---|-------------x-----|--->
   prevPhi             newPhi

So assume that we are under the situation like above. Point x is where the surface lies which is closer to B. The ray is marching from left to right, with fixed step _resolution (the interval between the bars |). If newPhi has different sign with prevPhi, we want to compute the distance of x between point A and B. To get the approximated distance, we are using fractionInsideSdf function which measures how much the negative SDF region is occupying the line segment AB.

For example, if prevPhi is -0.7 and newPhi is +0.3 (just some arbitrary numbers that make x closer to B), fractionInsideSdf will return 0.7, where the current code will return the right distance from A which is _resolution * 0.7. However, if prevPhi and newPhi are +0.7 and -0.3, the function will lead to _resolution * 0.3 which is not the correct distance from A to x.

Let me fix the code and merge to the master soon.

Thanks,
Doyub

@doyubkim
Copy link
Owner

doyubkim commented Aug 8, 2017

Just merged the fix to the master. Please let me know if you have further questions!

@doyubkim doyubkim closed this as completed Aug 8, 2017
@Immocat
Copy link
Author

Immocat commented Aug 9, 2017

Thanks for your detailed explanation. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants