Evenly Spaced Points on Sphere / Fibonacci Lattice
peter_1776
Member Posts: 6 ✭
First off: I understand I can do something similar using patterns, but that is not my goal
Apparently it is not possible to get perfect spacing of points on a sphere (with a few exceptions). While mathematicians may be distraught over this, engineers can use Fibonacci Lattice to accomplish a 'close-enough' result. I would like to have this function available. The code for creating the 3D points is rather simple, but I don't know enough about Onshape internals (nor programming for that matter) to do this on my own.
I believe I can code the creation of a matrix of 3d points in FS, but that's all at this point. What are the steps to make this happen?
This is my guess:
1) Input sphere diameter, boolean body diameter (sphere for now), number of instances, boolean operation (add/subtract)
2) Generate sphere of variable diameter
3) Generate body to boolean pattern
4) Create 3D matrix of points
*At this point, a similar FS (SurfacePattern) seems to do planes and normals, which I'm not sure whether it's necessary.
*I also am not clear if calculations should be in radians or degrees, though I can play with that
5) Pattern boolean body at each 3D point
6) Perform boolean operation for bodies
Appreciate any feedback or direction on this.
0
Comments
-
That sounds perfectly reasonable and not too difficult. There are plenty of people on this forum that would be glad to help! You don't have to physically create the 3D points, just the transformations (then use opPattern). For the calculations, you can specify if it is degree or radian.Senior Director, Technical Services, EMEA1
-
Thanks for the feedback! It helped me get from point A to B.
I've got patterning done, it seems correctly, but I need to shift the origin of the pattern to a selected mateConnector. I know how to select it, but I am not clear how shift it.0 -
If it helps my Parametric Curve FS can be used to generate a curve on a sphere. That curve can then be used with the Curve Pattern feature to generate bodies along the curve. It won't be exact, but it's close to an out of the box solution using already completed features and FS.

1 -
Thanks Mahir! I will probably find a use for that in a different project. The key point about the Fibonacci Lattice is that the points get spaced as evenly as is possible. The curve pattern won't space evenly over the sphere, only evenly along the curve.I figured out a way to accomplish my previous 'shift' (transform) issue. Probably not the best, but it works.A new issue: I can't find documentation on creating a random variable/constant. I came across a rather complicated FS that does it, but surely there is a random number generator?0
-
No, there is no random number generator, nor can you access any data that might change over time, like date/time. This is done on purpose so that the feature regenerates the same way every time - imagine if your points moved every time you rebuilt the model - chaos. The FS creates a pseudo-random number, but it will be the same every time it rgenerates.peter_1776 said:Thanks Mahir! I will probably find a use for that in a different project. The key point about the Fibonacci Lattice is that the points get spaced as evenly as is possible. The curve pattern won't space evenly over the sphere, only evenly along the curve.I figured out a way to accomplish my previous 'shift' (transform) issue. Probably not the best, but it works.A new issue: I can't find documentation on creating a random variable/constant. I came across a rather complicated FS that does it, but surely there is a random number generator?Senior Director, Technical Services, EMEA0 -
NeilCooke said:
No, there is no random number generator, nor can you access any data that might change over time, like date/time. This is done on purpose so that the feature regenerates the same way every time - imagine if your points moved every time you rebuilt the model - chaos. The FS creates a pseudo-random number, but it will be the same every time it rgenerates.peter_1776 said:Thanks Mahir! I will probably find a use for that in a different project. The key point about the Fibonacci Lattice is that the points get spaced as evenly as is possible. The curve pattern won't space evenly over the sphere, only evenly along the curve.I figured out a way to accomplish my previous 'shift' (transform) issue. Probably not the best, but it works.A new issue: I can't find documentation on creating a random variable/constant. I came across a rather complicated FS that does it, but surely there is a random number generator?
3



