Jump to content

Getting vectors from edges


Recommended Posts

Hey

try in a wrangle sop:

vector P2 = point(0, "P", @ptnum+1);
v@normal = normalize(@P-P2);

This will generate a normalised normal from point 0 towards point .
But the basis is to subtract position B from position A.
You do might have to add an exception for the last point so it used point 0.

Link to comment
Share on other sites

// Point wrangle.

vector edge_dirs[];
foreach (int nb; neighbours(0, @ptnum))
{
    vector pos = point(0, "P", nb);
    vector edge_dir = normalize(@P - pos);
    append(edge_dirs, edge_dir);
}
vector edge_normal = normalize(avg(edge_dirs));
@N = edge_normal;

Here the sample code for edge normal vector. After foreach you have an array of normalized deltas between point and it's neighbours. If you need true length vectors as an array attribute, you may simplify the code to something like this:

// Point wrangle.

foreach (int nb; neighbours(0, @ptnum))
{
    vector pos = point(0, "P", nb);
    append(v[]@edge_vectors, @P - pos);
}

 

Edited by f1480187
  • Like 2
Link to comment
Share on other sites

Thanks Maurits, but this is not what i need. 

I have point and few edges from it to other points. I know the point number and i need makes vectors from this point along edges to others.

Edited by tamagochy
Link to comment
Share on other sites

You can check if your point is connected to another point with pointedge().

int myPointId = 1;
vector myPoint = point(0, "P", myPointId);

v@Cd = set(1,0,0);
if( @ptnum != myPointId)
{
    int pe = pointedge(0, myPointId, @ptnum);
    if( pe > -1)
    {
        vector edgeVector = @P - myPoint;
    }
}

Of course this iterates over all points of the geometry. It could help to do some reduction, maybe with a special attribute, promote this attribute to primitives and delete all primitives which do not have this attribute. This way you reduce the number of possible points to a minimum.

Link to comment
Share on other sites

51 minutes ago, f1480187 said:

// Point wrangle.

vector edge_dirs[];
foreach (int nb; neighbours(0, @ptnum))
{
    vector pos = point(0, "P", nb);
    vector edge_dir = normalize(@P - pos);
    append(edge_dirs, edge_dir);
}
vector edge_normal = normalize(avg(edge_dirs));
@N = edge_normal;

Here the sample code for edge normal vector. After foreach you have an array of normalized deltas between point and it's neighbours. If you need true length vectors as an array attribute, you may simplify the code to something like this:


// Point wrangle.

foreach (int nb; neighbours(0, @ptnum))
{
    vector pos = point(0, "P", nb);
    append(v[]@edge_vectors, @P - pos);
}

 

Thats what i need. Thanks!

Link to comment
Share on other sites

I made some setup, but with this object when i use point 0 its not working. Some other points work some not. I dont understand what happen.

This is importet geometry from alembic made in max. When i create the same object in houdini its work.

send-1.zip

Edited by tamagochy
Link to comment
Share on other sites

There is complex network at the end, do you check if everything is working with it? If it is not working as expected, try to change:

append(v[]@arr, @P - pos);
append(v[]@arr, pos - @P);

It will reverse edge vectors (edges has two possible directions). It is a first thing I would try. For checking use as simple stuff as possible:

// Point wrangle.
@N = v[]@arr[0];

Turning normals on will show this vectors. Note, that normal lengths are scaled down five times by default in viewport (Display Options / Guides tab / Guide sizes block / Scale Normal).

Link to comment
Share on other sites

This setup work normal with any geometry maked in houdini. But with this imported not. This setup not use direction it use only length of the vectors, so reversing change nothing.

Main problem it is a 0 side and up vectors. but if change point number to 1 its work, with point 4 i get 2 vectors, but problem not in setup because for houdini geomery all ok.

Iam isolate point 0 and check vectors from array. There are looks normal but why its not work i dont understand.

I check once agane looks its problem of the last modul.

Edited by tamagochy
Link to comment
Share on other sites

I want to make automatisation of fracturing wooden beams from imported geometry. This vectors give me origin point for make matrix transform of the beam and orient longer side to x axis and make fracturing. Then i back it to place.

I think about adding searching for prim area to take points only from biggest prims to avoid small edges.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...