MoI discussion forum
MoI discussion forum

Full Version: Nodebundle for playing with nodes

Show messages:  1-6  …  1367-1386  1387-1406  1407-1426  1427-1446  1447-1466  1467-1486  1487-1506  …  1847-1859

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

From: bemfarmer
3 Apr 2019   [#1427] In reply to [#1426]
Some tentative thoughts:

What kind of center/centre is being sought?

Bounding box center may not find the desired center. Nor CenterAtOrigin script.

Centroid finding may require some integration, or calculations involving many points.

Prior center of mass/ centroid results: https://moi3d.com/forum/index.php?webtag=MOI&msg=9270.16

The area.js script that I have does not work in MoI4Beta.

- Brian
From: James (JFH)
3 Apr 2019   [#1428] In reply to [#1427]
Brian,

>> What kind of center/centre is being sought ? <<

The Centre as defined by Object Snap.

Hope this helps,
James
https://www.instagram.com/nodeology/

Image Attachments:
findCentre.gif 


From: Michael Gibson
3 Apr 2019   [#1429] In reply to [#1427]
Re: center - here are some relevant script properties and functions that were added a while ago in V4. These can be called on a curve or a curve segment:

crv.isPlanar - Property that returns true if the curve's control polygon is planar.

crv.planarFrame - Property that returns a coordinate frame with an origin point at the curve's control polygon centroid and a z axis along the plane normal, only valid if crv.isPlanar == true.

crv.isOnPlane( frame ) - Function that returns true if the curve is on the given frame's x/y plane.

crv.isOnParallelPlane( frame ) - Function that returns true if the curve is on a plane parallel to the given frame's x/y plane.

crv.isClosed - Property that returns true if the curve is closed.

crv.isPeriodic - Property that returns true if the curve has periodic ends (overlapping control points at start/end rather than a corner point at the start/end).

crv.isDegenerate - Property that returns true if the curve has a degenerate control polygon with all the points stacked in the same spot.

crv.isLine - Property that returns true if the curve has the shape of a line.

crv.isSimpleLine - Property that returns true if the curve is a simple line segment made up of only 2 control points.

crv.isCircle - Property that returns true if the curve is a circle.

crv.isArc - Property that returns true if the curve is a circular arc.

crv.isEllipse - Property that returns true if the curve is an ellipse (either a full ellipse or an elliptical arc).

crv.conicFrame - Property that returns the coordinate frame of a circle, arc, or ellipse. Only valid if isCircle, isArc, or isEllipse returns true.

crv.conicRadius - Property that returns the radius of a circle, arc or the x-axis radius of an ellipse. Only valid if isCircle, isArc, or isEllipse returns true.

crv.conicRadiusY - Property that returns the y-axis radius of an ellipse. Only valid if isEllipse returns true.

crv.conicEndAngleRadians - Property that returns the end angle in radians of a circular arc. The arc starts at the x-axis of the arc's frame. Only valid if isArc returns true.


- Michael
From: James (JFH)
3 Apr 2019   [#1430] In reply to [#1429]
Thank you Michael for the info.
Is there a script property that returns the center point of polygons (regular & nonregular) and ellipses, just as does “Center” Object Snap?

Thank you for your help,
James
https://www.instagram.com/nodeology/
From: FDP
3 Apr 2019   [#1431] In reply to [#1430]
Win 7 64/MOI 3 here. Is there a simple up to date download and install guide for Nodeeditor/bundle? About a year ago I tried to migrate over from grasshopper and ended up giving up due to the time spent trying to get a working setup that reliably ran .nod files from people in this thread. Reading through the Wiki it seems like not much has changed, although there are some docs in the doc thread.
From: Frenchy Pilou (PILOU)
3 Apr 2019   [#1432]
That is missing is a little image for each script posted! ;)
not the script itself but the result!
From: Michael Gibson
3 Apr 2019   [#1433] In reply to [#1430]
Hi James,

re:
> Is there a script property that returns the center point of polygons (regular & nonregular)
> and ellipses, just as does “Center” Object Snap?

For an ellipse see the isEllipse and conicFrame properties listed above. You'd do something like:

 if ( crv.isEllipse )
 {
      var center = crv.conicFrame.origin;
      ...

For a polygon there is not any single property for that but it can be computed the same way MoI does by the centroid of the polygon vertices.

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, 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.

- Michael
From: James (JFH)
4 Apr 2019   [#1434] In reply to [#1433]
Hi All,

Here's a macro for calculating centroid of polygons (reg & nonReg) & ellipses (incl circles),
based on Michael suggestion above. (thanks Michael, it seems so obvious now)

However, it is of limited use, because it is not multi-processing; which is to say,
that it could not be wired to a faceted surface; outputting the centroid of each individual facet.

For that a dedicated node is required.
Any takers?
James
https://www.instagram.com/nodeology/
From: bemfarmer
4 Apr 2019   [#1435] In reply to [#1434]
I'm missing extractPts node...
I'll have to check your (James') recent posts...
(or maybe it was recently moved...
- Brian
From: James (JFH)
4 Apr 2019   [#1436] In reply to [#1435]
Brian,

Try extension folder attached here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=7777.1404

It is the most up-to-date.

James
From: bemfarmer
4 Apr 2019   [#1437] In reply to [#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
From: James (JFH)
4 Apr 2019   [#1438] In reply to [#1437]
Thanks Brian,
If you can, it would be greatly appreciated
Have a great weekend,
James
https://www.instagram.com/nodeology/
From: bemfarmer
5 Apr 2019   [#1439] In reply to [#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
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/

Show messages:  1-6  …  1367-1386  1387-1406  1407-1426  1427-1446  1447-1466  1467-1486  1487-1506  …  1847-1859