Comments (8)
So:
func Sub(a, b V3) V3
Instead of:
func (a V3) Sub(b V3) V3
The advantage of the second form is that it leaves "Sub" free in the namespace to be used for other types. E.g. V2, integer vectors, etc.
I think that's why I selected it. Blame a lack of function templates in go.
from sdfx.
What you are saying is reasonable. This namespace constraint however can be solved by creating a package for each type much like gonum does.
from sdfx.
This namespace constraint however can be solved by creating a package for each type
Done.
I haven't created an c = op(a, b) functions at this time, but it is trivial to do so.
from sdfx.
Awesome! I guess as soon as those functions are written we can close this issue. I am unavailable to contribute this feature.
from sdfx.
@soypat you could however do:
n := a.f(t + dt2).Sub(a.f(t - dt2))`
couldn't you?
from sdfx.
@aprice2704 my issue is not with the amount of lines it takes to express an operation but rather how readable the code is. I dont think methods as operations lend themeselves to readable code, in my experience
from sdfx.
I understand but respectfully disagree :) I find the method-operator version to be clearer, since it enforces the order in which operators are applied rather than relying on conventions from natural languages.
sub(a,b) results in a-b or b-a?
a.sub(b) must be a-b.
I have been writing a fairly complex set of geometry manipulations and found the operator-method to be quite clear. :)
In any event, the methods being present do not constrain you from adding sub(a,b) and friends to your own packages if you wish; however, adding methods requires forking the package, so I would much prefer @deadsy leaves them in place :)
from sdfx.
At this point the vector packages have been split out into individual packages for each vector type. The rest of the code has been converted to use the new packages.
At the moment the a.Op(b) for is still the main way of doing things.
The Op(a,b) form is possible without leading to name space problems.
E.g. v2.Add(a,b)
Still- I haven't created these functions, because I don't feel the need.
from sdfx.
Related Issues (20)
- Zero length line segments ruin Polygon2D objects HOT 1
- obj/screw.go: NPT thread HOT 2
- Removing returned errors from shape generation functions HOT 10
- Request to add pointer to `sdf` project HOT 2
- Hollow out 3D meshes by this tool? HOT 3
- Bolts smaller than expected HOT 3
- Threads on package import HOT 4
- Gyroid shape HOT 1
- Feature Request: Extract Vertex Data to an Array HOT 2
- Pack models together tightly HOT 3
- How to duplicate SDF? HOT 5
- How to check if intersection is empty or not HOT 7
- Time consumption of marching cubes algorithm HOT 1
- Initialize a 4x4 matrix i.e. `sdf.M44` HOT 9
- Description Language idea.. HOT 3
- STL to SDF evaluation HOT 1
- Creating an arbitraty shape for a chain HOT 1
- Build error HOT 3
- Whether to support dxf file parsing? HOT 3
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 sdfx.