Nodebundle for playing with nodes
 1-16  …  1397-1416  1417-1436  1437-1456  1457-1476  1477-1496  …  1857-1859
Thread Split: Some posts in this thread have been moved here

Previous
Next
 From:  bemfarmer
7777.1437 In reply to 7777.1436 
Thank you James. Extensions are now updated.
I'll take a look at doing a mutiprocess, but am quite busy now, with limited play time, so no promises :-)

- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  James (JFH)
7777.1438 In reply to 7777.1437 
Thanks Brian,
If you can, it would be greatly appreciated
Have a great weekend,
James
https://www.instagram.com/nodeology/

EDITED: 5 Apr 2019 by JFH

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
7777.1439 In reply to 7777.1434 
Hi James,

After some thought, it seems that the Input objects to a centroid node need to be defined.
It is necessary to "parse" the Input object into Cases, which should be possible with multiple IF statements.

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

So far the centroid is being sought for Circles, Ellipses, and Closed Planar polygons consisting of line edges.
I've re-read Wikipedia centroid topic, and the centroid also applies to a closed planar polygon with a circular hole in it.

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.

What about wireframe objects? Maybe planarize them?

At present, the centroid only applies to planar objects, or planar faces of 3D objects.

Example objects: Cube, open cube, cuboid, tapered cuboid, tetrahedron, icosahedron, nonRegular solid with planar faces,
cylinder, rounded off tetrahedron with a circular faces, and edges rounded off...

A look at scripts which handle faces might be helpful.

- Brian

Wikipedia also describes centroids for regions bounded by two continuoiu functions. Are NURBS curves continous functions, that would qualify? (Integration required...)

Centroids of NURBS bounded areas are possible to calculate. There is one Chinese article, but it was not downloadable...
Maybe for MoI version 6, Michael will create a factory for centroids... :-)

This is another link:
https://www.intmath.com/applications-integration/5-centroid-area.php
http://web.mst.edu/~ide50-3/schedule/lessons/21_Centroids.pdf

EDITED: 5 Apr 2019 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  speedy (AL2000)
7777.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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  James (JFH)
7777.1441 In reply to 7777.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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7777.1442 In reply to 7777.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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  James (JFH)
7777.1443 In reply to 7777.1442 
Michael,

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

James

EDITED: 5 Apr 2019 by JFH

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7777.1444 In reply to 7777.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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7777.1445 In reply to 7777.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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  James (JFH)
7777.1446 In reply to 7777.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/
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7777.1447 In reply to 7777.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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
7777.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...

EDITED: 7 Apr 2019 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
7777.1449 In reply to 7777.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

EDITED: 7 Apr 2019 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
7777.1450 In reply to 7777.1449 
Draft4, a little progress made, but node is still broken.

EDITED: 8 Apr 2019 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
7777.1451 In reply to 7777.1450 
Alert messages were added to see what is going on, or not going on.
I left off the () for getStartPt()...
 
- Brian

EDITED: 8 Apr 2019 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
7777.1452 In reply to 7777.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.

EDITED: 9 Apr 2019 by BEMFARMER


  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Message 7777.1453 deleted 12 May 2019 by JFH

Previous
Next
 From:  bemfarmer
7777.1454 In reply to 7777.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:-)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  James (JFH)
7777.1455 In reply to 7777.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/

EDITED: 9 Apr 2019 by JFH

Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
7777.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

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
Show messages:  1-16  …  1377-1396  1397-1416  1417-1436  1437-1456  1457-1476  1477-1496  1497-1516  …  1857-1859