MoI discussion forum
MoI discussion forum

Full Version: Nodebundle for playing with nodes

Show messages:  1-19  …  1380-1399  1400-1419  1420-1439  1440-1459  1460-1479  1480-1499  1500-1519  …

Thread Split: Some posts in this thread have been moved here

From: speedy (AL2000)
5 Apr 2019   [#1440]
Hi James and Friends
I did this exercise, before loading the New Extensions
and in particular (extractPt ...) ;
but the result is similar to your ...
The real problem is that you can't get it to flow together
multiinput ... (Grasshopper with its branching, it could be
an inspiration to be able to reach this milestone in the future)

the file at this link:
http://www.mediafire.com/file/8d3b6uwm1a6455y/Baricenter_and_BBox_Center.zip/file
Have a nice Week-end to all
alberto
From: James (JFH)
5 Apr 2019   [#1441] In reply to [#1439]
Hi Brian,

>> centroid also applies to a closed planar polygon with a circular hole in it <<.

I think, for the sake of simplicity, we need only concern ourselves with planar, closed polygons.
We can disregard for now compound surfaces and even ellipses for that matter.

>> A faceted surface, (possibly 3D), would be broken down into Faces, inside or outside of the node, and each face tested to see if a centroid applies. <<.

Again for simplicity, we need only concern ourselves with faces i.e. "broken down ....outside of the node"

In this way node need only be limited to Michael's second case steps
http://moi3d.com/forum/index.php?webtag=MOI&msg=7777.1433

>> You'd do something like look at .isClosed and .isPlanar and if both of those are true get the curve segments by crv.getSubObjects() then go through all segments testing .isLine on each one, <<

So we now know that all faces are indeed polygons, then

>> if all are lines go through them and add together all the segment start point coordinates and divide by the number of points to get the centroid. <<

>>I do not think that a node multiprocess sub function is required, (?), just sequential processing of the input objects, with For loops.<<.

If a for loop satisfies the requirement of determining the centroid of multiple faces, all the better.

Thanks for looking at this
Have a great weekend
James
From: Michael Gibson
5 Apr 2019   [#1442] In reply to [#1441]
Hi James & Brian - in James' post here: http://moi3d.com/forum/index.php?webtag=MOI&msg=7777.1428 it looked like you were asking about polygon curve objects. Polygon surface objects would be a little different, currently there aren't properties like .isPlanar exposed for surfaces like there are for curves.

- Michael
From: James (JFH)
5 Apr 2019   [#1443] In reply to [#1442]
Michael,

Would the additional step of getEdges (or getJoinedEdges ) method at the start, applied to input faces resolve this?

James
From: Michael Gibson
5 Apr 2019   [#1444] In reply to [#1443]
Hi James,

re:
> Would the additional step of getEdges (or getJoinedEdges ) method at the start, applied to input faces resolve this?

It will work for getting the centroid of a face that you already know is planar but it won't work for determining if a face is planar or not. It is possible to have a face where the surface is not planar even though all its edge curves are on one plane.

The edge curves of a face are not necessarily ordered start to end like the segments of a curve are, so you'd need to gather the points a little differently. Probably the easiest is to accumulate both the start and the end point of each curve.

- Michael
From: Michael Gibson
6 Apr 2019   [#1445] In reply to [#1443]
Hi James, for the next v4 beta I've added in some new script properties and functions for faces that should help with this. There will be an .isPlanar property for faces then and also support for evaluating points, normals and derivatives on faces.

- Michael
From: James (JFH)
6 Apr 2019   [#1446] In reply to [#1445]
Hi Michael,

Was this always on the cards, or is it in response to my enquiries regarding face centroids?
If it is the latter, I don't know what to say.....but thank you.

Well, either way
thank you.

James
https://www.instagram.com/nodeology/
From: Michael Gibson
6 Apr 2019   [#1447] In reply to [#1446]
Hi James, well it's been something I've been planning on adding for some time now but your particular request about it bumped it up!

One thing that tends to make me hesitate in this area is that once script interfaces are added it becomes pretty difficult to change them since there gets to be various things depending on it. So if I mess it up it's something that easily stays messed up for kind of a long time... But here the equivalent is already in there for curves so I can follow the same structure for faces too.

- Michael
From: bemfarmer
6 Apr 2019   [#1448]
It is a rain day, so from 6:30 AM to 8 AM, some initial centroid work was done.
A break is now required, so here is some non-functional code :-)

The task is so easy to understand, yet so hard for this slow amateur programmer to code... :-)

The non functional draft node can be copied to the nodeeditor extension folder, to add it to the construct2 menu.
The node may then be selected from the construct2 menu, and the node is displayed, but does not function further.

- Brian

Bogging down again, so 2nd break...got to go do some work...
From: bemfarmer
7 Apr 2019   [#1449] In reply to [#1448]
Draft3, non functional, but getting closer
(completely untested)

Using both start and end points of each subobject, so length *= 2.
Planar poly, but with z coordinates, needs zsum/(length*2)

- Brian
From: bemfarmer
7 Apr 2019   [#1450] In reply to [#1449]
Draft4, a little progress made, but node is still broken.
From: bemfarmer
8 Apr 2019   [#1451] In reply to [#1450]
Alert messages were added to see what is going on, or not going on.
I left off the () for getStartPt()...
 
- Brian
From: bemfarmer
8 Apr 2019   [#1452] In reply to [#1451]
Here is an early beta version, which actually works in the xy plane, for 3+ planar poly objects.
Further testing needed.
Test 2D polys in 3D space, Poly triangles of portion of an icosahedron, is working.

Copy CentroidNode.js to nodeeditor\nodes\extensions folder.

For Testing, open Ico5Poly.3dm, of color Orange.
Also Load PolyCentroidNodeTest3.nod into nodeeditor, or some other test .nod, and Run it.

The extra point at the origin is to be investigated. EDIT, the pointarray centroidPt (pink node dot and pink wiring), is defective. (Should not be curve mode either.)

- Brian

Earlier a strange effect occurred. An icosahedron was loaded from Obj Library. 15 edges of 5 side faces were joined to form 5 polygons. Did a 2X scale of, and moved, the "Ico5Poly"
Icosahedron was deleted.
Running the CentroidNode found the centers of the Ico5Poly, But strangely also caused the orange icosahedron to re-appear.

Edit: See post 1456 for beta3.

Attachments:
IcosahedronPolyPortionTest.zip


Message 7777.1453 was deleted


From: bemfarmer
8 Apr 2019   [#1454] In reply to [#1453]
Thank you James.
It is easy enough to modify CentroidNode.js to load in the Points2 menu,
or else to just copy paste the code to the Points2 menu, minus a very few characters at beginning and end of CentroidNode.js.

I'm not sure how easy it is to convert from faces to polygon outline with miscellaneous nodes. Or if the CentroidNode should have face to edges to polygon feature added, along
with the next MoI Beta, pending Michaels upcoming surface.isPlanar property, as per previous posts.

The pink centroidPt output is still broken...AFAIK.

The script has barely been tested...

Might as well add circle and ellipse?

- Brian

Integration for closed curves centroids is still a dream:-)
From: James (JFH)
8 Apr 2019   [#1455] In reply to [#1454]
Brian,

>> Might as well add circle and ellipse?.....
Integration for closed curves centroids is still a dream:-) <<

Centroid for these shapes can be can be found by using subD/convertCurveToPoly node
before centroid node. Obviously the higher the "Div Profile" the more accurate.
For circles, any even number (except 0) input to "Div Profile" will give true centre.


For now I think your work is done here. I'd just remove centroidPt output socket.

I'm not saying it is not worth spending any more time on it, just that it good enough for now.
If you are keen to keep coding, in term of outcomes it would be better to investigate other possible nodes.
To this end, I have a suggestion, if you are interested: FATLINES.

A Fatlines node analogous to Max's scripts of the same name would be a real boon IMHO to NE.
Think islamic patterns, for example. Anyway its just a thought.

James
https://www.instagram.com/nodeology/

Image Attachments:
closedCurves.gif 


From: bemfarmer
9 Apr 2019   [#1456]
CentroidNodeBeta003

The file is still in its own .js node wrapper, but has been moved to the Points2 menu. (not the Points2.js file, which could/should be done.)
So after placing beta003 in the extensions folder, if the node appears red in your .nod program, replace the node with the one from the Points2 menu.

Also fixed the raw centroid point(s) output (Pink) with the proper code, as shown in Objects.js/ObjtoArray node. (output2.pushPoint(cPtObj.item(0).pt);)
(Just use either the centroidObj point output, or the pink output, to avoid duplicate points...)

Note that Max's cVolume2 script finds centers of gravity for one extruded closed planar object, including extruded curved closed planar objects.
It seems to be a very long script.

Will look at FatLines.

- Brian

Attachments:
CentroidNodeBeta003.zip
PolyCentroidNodeTest4.zip


From: James (JFH)
10 Apr 2019   [#1457]
Just for a bit of Conic Relief



Node circuitry images post to: https://www.instagram.com/nodeology/

James

NE folder can be found here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=9358.1

Attachments:
ConicRelief.nod

Image Attachments:
ConicRelief.jpg 


From: Frenchy Pilou (PILOU)
10 Apr 2019   [#1458] In reply to [#1457]
Cool image for Bees! (and for enlight users about subject of Nodes ! ;)

Sorry I have no times for the moment manage all nodes for a years! :(
From: bemfarmer
10 Apr 2019   [#1459] In reply to [#1457]
Hi James,
Do you have a link to "WaveSurf"?

For your old ProjectSurf.nod, replacing red Project node with Construct1/ProjectMP enabled the .nod to run.

- Brian

Your old paraSurf.nod has a couple of red nodes...in the copy I have.

Show messages:  1-19  …  1380-1399  1400-1419  1420-1439  1440-1459  1460-1479  1480-1499  1500-1519  …