Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Most efficient way to turn a curve into a list of numbers?
EvanReese
Member, Mentor Posts: 2,135 ✭✭✭✭✭
This is for the Attractor Pattern feature. I want to add the ability for the user to draw a custom falloff curve for the pattern that will change the way the number range is distributed. Currently, the falloff is linear, as in the image on the right. I'd like to be able to draw an s-shaped spline on the top plane (or any arbitrary curve), and get the result on the left (which I've just faked here by using a different base surface). Since there are potentially so many instances, I'm looking for the most lightweight strategy to get these new numbers, while still giving the user full control over the curve shape. Anybody have any ideas about how to do it efficiently?
My initial thought was to use raycast to find the xy coordinate at each point on the curve, which I think could work, but it can take a few seconds when the point count gets into the thousands. Does someone know a more efficient way?
My initial thought was to use raycast to find the xy coordinate at each point on the curve, which I think could work, but it can take a few seconds when the point count gets into the thousands. Does someone know a more efficient way?
Evan Reese
0
Answers
Asymptotic decay
y = e^(-ax)
Exponential decay
y = 1-e^a(x-1)
Sinusoidal
y = .5(1+cos(πx))
Circular/elliptical
y = sqrt(1-x^2)
Parabolic
y = 1-ax^2
General polynomial
y = ax + bx^2 + cx^3...
https://sighack.com/post/easing-functions-in-processing
https://bitbucket.org/kluivers/jk-interpolation/src/master/JKInterpolationMath.m