-
Notifications
You must be signed in to change notification settings - Fork 130
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
Changed a few things in sphere, cylinder and functions. #10
base: master
Are you sure you want to change the base?
Conversation
Very cool! My intention with the API was to do it as described here: https://github.com/fogleman/ln#custom-texturing That is, creating a "subclass" that overrides Paths() instead of passing in a Paths() implementation. You can also see OutlineSphere as an example of that. I am interested in integrating your work but would like to head that direction. Do you think you can refactor your pull request with that in mind? Also, thanks for renaming my bad ones like Paths2(), Paths3() 😄 |
func RandomUnitVector() Vector { | ||
for { | ||
x := rand.Float64()*2 - 1 | ||
y := rand.Float64()*2 - 1 | ||
z := rand.Float64()*2 - 1 | ||
if x*x+y*y+z*z > 1 { | ||
if x == 0 && y == 0 && z == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change would result in some bias in the random vectors.
Part of the thinking behind doing it that way was so the subclass could include other configuration / parameters. For example a GridFunction type could include parameters for the grid size. |
Hi, TBH, this code is actually a backport of my Python port of ln. I did that because I initially didn't have go installed and wanted to try to port it to see how it would go. Turns out Python is much slower than compiled go, so what gain I have not compiling is lost at runtime. Anyway, that's why I had this pluggable-function approach, since it is easy and natural in Python. Other changes I did were in line with your recent changes: refactor out cairo for another lib. (I had used vmimg.) As such, my pull rquest was already a refactor of a backport from Python, so feel free to simply rewrite my changes as you see fit. I don't think I'll be very active anyway. |
BTW, FWIW, my port to Python revealed two potential issues with the code that I didn't backport:
|
Cool, thanks for the info! |
I have done some refactorization: created multiple function sub-classes and put back the random vector stuff. |
Added new Paths implementations. Made the one in function.go pluggable at run-time.