Show messages:
1-9
…
150-169
170-189
190-209
210-229
230-249
250-269
270-289
…
410-425
From: James (JFH)
edgesNums Node
The proposed node would parse input surfaces & output a numArray of the number of sides of each item.
It could be used together with logic/compare & split nodes to isolate surfaces of a designated number of sides.
(I have only included an "Out" output, to reduce the tedious need for Object/Clone node prior.)
James
https://www.instagram.com/nodeology/
Image Attachments:
edgesNums.gif
From: James (JFH)
vecLerp node
The proposed node would generate new vector that is a linear interpolation between 2 input vectors.
See this link for clear explanation:
https://p5js.org/reference/#/p5.Vector/lerp
James
https://www.instagram.com/nodeology/
Image Attachments:
vecLerp.gif
From: bemfarmer
Michael's randomize script defines two simple Lerp functions.
code:
function Lerp( low, high, t )
{
return low + (high-low)*t;
}
function RandLerp( low, high )
{
return Lerp( low, high, Math.random() );
}
Wikipedia has a more accurate return formula, for floating point. (?)
Need to define Lerp function for vectors, (x, y, z points).
Linearly interpolate between vector v1, and vector v2.
lerpVectors ( v1, v2, interpolationFactor )
v1 - the starting vectpr.
v2 - the vector to interpolate towards.
interpolation factor, typically in the closed interval [0, 1].
- Brian
So regular javascript does not have a lerp function (?)
So the 3d lerp function must be defined in terms of simpler javascript commands.
Found 2d lerp function here:
https://www.redblobgames.com/grids/line-drawing.html
code:
1d: function lerp(start, end, t) {
return start + t * (end-start);
}
function lerp_point(p0, p1, t) {
return new Point(lerp(p0.x, p1.x, t),
lerp(p0.y, p1.y, t));
}
Note: to do 3d vector lerp, add
code:
lerp(p0.z, p1.z, t)
to the redblob code.
(Use vectorLerp() (?))
This vectorLerp is a bit confusing...negative numbers? low > high, clamping t? angleLerp vs quaternionLerp, floating point problems...
But I think that this proposed node is relatively easy to do, once understood.
Then smooth motion Move of an object could be done...
t is usually between [0, 1], but does not have to be.
negative t might be a problem?
Negative low and high, and low > high might be problems?
A good link:
https://danielilett.com/2019-09-08-unity-tips-3-interpolation/
From: bemfarmer
Significant editing was done to prior post.
Due to limited understanding of Lerp, it might be best to write the node, then worry about what if
negative numbers are used, clamping is needed, or vector1 x1, y1, z1 coordinates vs vector2 x2, y2, z2 coordinates are not always low...high, or ?.
- Brian
From: bemfarmer
Do regular value Lerp with math node(s).
Do vectorLerp with a nodeeditor Macro?
Brian
From: bemfarmer
Draft of a Lerp macro for number values.
Partial draft of a LerpVector node for v1 = (x1, y1, z1), v2 = (x2, y2, z2).
It uses pairs x1 and x2 for a and b inputs to one of three copies of the Lerp macro. Similarly for y1, y2 and z1, z2.
The three X, Y, Z outputs are the resulting interpolated vector.
The c input is the interpolation factor, == t, normally from [0 to 1]. Use slider widget?
So a vector could have its X, Y, Z split out...? (For v1 and v2)
untested.
- Brian
The javascript code of the existing vector nodes, versus the pointarray datatype are nearly incomprehensible for myself :-)
I went back to some of the old posts by Max and Karsten, about the pointarray data structure, and its 10 elements,
and wrote up some documentation, but still do not understand a lot...
With a slider input to c, the node works, but there seems to be a scale factor of 2, somehow.
See next post for two macros and node.
From: bemfarmer
Here is an updated LerpVectorMacro, which can be placed in the Macro folder, along with LerpMacro.
Also is the node program using the two macros, lerpVectorTest2 node.
2X "scale" bug still present.
The LerpVectorMacro contains 3 copies of the LerpMacro.
- Brian
To save a macro, (for example LerpMacro), export LerpMacro from the canvas to a folder, naming it LerpMacro.nod.
Then copy the file LerpMacro.nod to the nodeeditor macros folder, for future re-use.
Similarly for LerpVectorMacro.nod, or any other Macro.
Attachments:
LerpMacro.nod
LerpVectorMacro.nod
LerpVectorTest2.nod
From: wayne hill (WAYNEHILL5202)
New qhull3d Node:
Based on the qhull library:
https://github.com/bjnortier/qhull
http://www.qhull.org/
I would like to thank James for helping out with testing.
Save all the files to this directory:
C:\Users\<UserName>\AppData\Roaming\Moi\nodeeditor\nodes\extensions
Input:
1. Points: At least three points to start the node.
Outputs:
1. Triangles: Line edge vectors to create planar faces.
2. Hull Pts: The outer most points of a point cloud being input.
3: Hull Pts Objects: The outer most object points of a point cloud being input.
Added a new Vector3d.js point class function for future projects.
Wayne
From: Frenchy Pilou (PILOU)
What is the the name of a "qhull" : a polyhedron ?
From: wayne hill (WAYNEHILL5202)
Qhull computes the convex hull from points.
https://en.wikipedia.org/wiki/Convex_hull
The attached image is a simple point cloud. Red spheres are the outer-most points of the cloud making up the hull. The lines are the triangles that make up the outer-most planes of the hull.
From: bemfarmer
WOW,
I dabbled a few years ago, but gave up.
Brian
Now to try it with spherePts...
From: bemfarmer
This link explains, in simple terms, the difference between static methods and instance methods,
in particular for a vector class. Its examples with PVector (from processing), essentially show how to use the Vector3d.js class. (FALSE)
https://www.khanacademy.org/computing/computer-programming/programming-natural-simulations/programming-vectors/a/static-functions-vs-instance-methods
- Brian
Note, after much confusion, the PVector examples are different from the way Vector3d is written.
So this post should be disregarded. The classes can be written in different, conflicting ways.
From: wayne hill (WAYNEHILL5202)
Brian,
Thank you! Max uses the Vector class on his Subdivide and the Cloth script. It was used on the original qhull source code.
Wayne
From: bemfarmer
Thank you Wayne.
I'll look at those other programs.
I have been puzzling over how to do add-on libraries, and how they are "linked", or accessed.
There seems to be multiple ways to write code.
It seems like nodeeditor/Javascript scans all the addons.
Would having ES6, (or ES11?), be of any benefit?
-Brian
From: wayne hill (WAYNEHILL5202)
Brian,
MoI's WebKit interface determines what resources are available for the Node Editor uses to ensure stability. My Javascript version is 1.7. ES6 or ES11 would more likely be on a different environment like a backend server Node box. The Node Editor startup scans the scripts and begins the background services. The scripts are scanned and linked in their filename order.
loadScripts('core', 'lang, compatibility, colors, geometry, main, editor');
loadScripts('nodes', 'macros, basic, logic, points, curves, solids, construct, transform, objects, interface');
loadScripts('nodes/extensions/libs', '*');
loadScripts('nodes/extensions', '*');
loadScripts('core', 'init, ext.*');
If you want to build a library calling other Javascript files, they have to be scanned (note filename order) before they are available for the other libraries to use.
Example directory:
1test.js
2test.js
3test.js (uses 1test.js and 2test.js and 4test.js)
4test.js
3test.js can use 1test.js and 2test.js libraries but not 4test.js library because it has not been scanned. Error will trigger on a missing script. It is not missing.
4test.js will have to be renamed to 0test.js in both 3test.js and it's filename.
New listing:
0test.js
1test.js
2test.js
3test.js (uses 1test.js and 2test.js and 0test.js)
Wayne
From: bemfarmer
Thank you Wayne.
It is very useful information.
- Brian
Message 9581.226 was deleted
From: bemfarmer
Note, I edited the post on PVector, because it works differently from Vector3d.
It almost works in the opposite way, which caused much confusion.
If object types do not match, javascript shows an error.
The way a class is programmed determines the way it works.
Other programmers have written vector classes, and complex number classes, with instance methods, and static methods, which behave very differently from what other programmers have written. I am not aware of any standard.
So I have been doing my own complex number class, cPlex, adapting the available conflicting code.
It has to be ES5 compatible as well, to be compatible with the javascript used by MoI4.
(A complex number class is very similar to a vector2d class.)
(mathJS has the needed functions, but is extremely complicated, ES11(+/-), BigInt, etc.
Then I can finish my script.
- Brian
Mixing real numbers with complex numbers makes it even more complicated.
From: wayne hill (WAYNEHILL5202)
Brian,
Learning both Javascript and Node Editor programming is confusing and complicated. Javascript code would work on the web browsers, but not in the Node Editor environment. That is when the version type the Node Editor uses make a difference. The scripting format of the Node Editor is very different from Javascript code. My Delaunay conversion script project changed a higher version of Javascript to a lower version to be compatible with the Node Editor. The Vector3D.js is a compilation of code from different sources. There are no documented standards to reference from for Node Editor programming. Learning from other users code, including your examples.
Wayne
From: bemfarmer
Thank you Wayne, for the clarifications.
I see that Max initiated a vector, before making the vector equal a vector subtraction.
Arrays and objecLists get initiated before use...
Now have a better understanding of why objects do not match, in my test code.
- Brian
Show messages:
1-9
…
150-169
170-189
190-209
210-229
230-249
250-269
270-289
…
410-425