Comments (4)
You can use %
, the modulo operator!
Though note that it can produce some pretty glitchy SDFs, due to the completely abrupt discontinuities; you really might prefer using a twirl after all. (I get use out of %
, but only in contexts where there's either plenty of empty space bordering the edges, or the edges always happen to line up smoothly; if you're trying to create an abrupt edge, modulo can't actually do that right, because it can't actually describe the 'open' faces that those edges leave behind!)
from libfive.
This is kind of what I figured (for why something like frac
is not included). I'll give twirl a whirl!
from libfive.
At first I was like, how with modulus? Then I realized .mod(1)
. It works damn perfect! I've got bolts again!
For anyone that needs it:
const mag = (x, y) => sqrt(x.square().add(y.square()));
const thread = (radius_, screw_) => {
const [x,y,z] = [X(),Y(),Z()];
const radius = Value(radius_);
const screw = Value(screw_);
const rad = mag(x,y).sub(radius);
const th = (
rad.sub(
abs(
z.mul(screw).sub(atan2(y)(x)).div(Math.PI / 2)
.mod(1)
.sub(0.5)
).div(screw)
)
);
return th;
};
const bolt = (diameter, height, pitch) =>
thread(diameter / 2, pitch)
.intersection(cylinder(diameter + pitch, height));
from libfive.
P.S. The twirl series of functions, while do twirl, do not twirl uniformly across the surface. Just a warning to anyone who uses them. They won't look like the twirling shown in my screenshot using my SDF.
from libfive.
Related Issues (20)
- Compiling on Fedore FC37 HOT 1
- Problem to compile libfive on FC37 HOT 8
- Embed Libfive in an application - general SDF Question HOT 4
- Feature request: Separate bounds/resolutions for different objects in the same scene? HOT 2
- Return multiple shapes without using union, in Python? HOT 4
- New url for inspekt3d HOT 2
- Double free or corruption error when trying to use libfive HOT 3
- Expose normals in libfive_mesh HOT 2
- Does Mesh::render consume the libfive_tree? HOT 3
- Unioning nothing at the top level causes things to mesh very slow HOT 6
- koffi and ffi-napi both segfault when meshing non-trivial models HOT 6
- Publish new release and set soversion for building shared libraries
- I've packaged this for OpenSuse
- Feature resolution is unexpectedly impacted by the size of the bounding box HOT 3
- Crash in DCTree<3u>::intersection
- QSocketNotifier error message
- Need precompiled Windows binaries of any kind HOT 4
- missing 'g++' package in Ubuntu instructions HOT 1
- Symbol visibility
- C5H12 is either moved or deleted
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libfive.