tamagochy Posted July 12, 2016 Share Posted July 12, 2016 I need to get vectors along edges conected to point. How can I achieve it? Thanks. Quote Link to comment Share on other sites More sharing options...
Maurits Posted July 12, 2016 Share Posted July 12, 2016 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. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted July 12, 2016 Share Posted July 12, 2016 (edited) // 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 July 12, 2016 by f1480187 2 Quote Link to comment Share on other sites More sharing options...
tamagochy Posted July 12, 2016 Author Share Posted July 12, 2016 (edited) 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 July 12, 2016 by tamagochy Quote Link to comment Share on other sites More sharing options...
haggi Posted July 12, 2016 Share Posted July 12, 2016 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. Quote Link to comment Share on other sites More sharing options...
tamagochy Posted July 12, 2016 Author Share Posted July 12, 2016 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! Quote Link to comment Share on other sites More sharing options...
haggi Posted July 12, 2016 Share Posted July 12, 2016 Oh, yes, neighbours() already returns directly via edges connected points, good to know. Quote Link to comment Share on other sites More sharing options...
tamagochy Posted July 13, 2016 Author Share Posted July 13, 2016 (edited) 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 July 13, 2016 by tamagochy Quote Link to comment Share on other sites More sharing options...
f1480187 Posted July 13, 2016 Share Posted July 13, 2016 Geometry imported as Polygon Soup primitive. Use Convert SOP to make it usual polygons. Quote Link to comment Share on other sites More sharing options...
tamagochy Posted July 13, 2016 Author Share Posted July 13, 2016 It first what i try but its not work after converting. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted July 13, 2016 Share Posted July 13, 2016 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). Quote Link to comment Share on other sites More sharing options...
tamagochy Posted July 13, 2016 Author Share Posted July 13, 2016 (edited) 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 July 13, 2016 by tamagochy Quote Link to comment Share on other sites More sharing options...
f1480187 Posted July 13, 2016 Share Posted July 13, 2016 (edited) The algorithm in vopnet is topology-dependent. When I scamble Houdini box ptnums, it's side and up vectors are also became zero-length. Make such, that does not depend on ptnums and order of vectors in the array. What are you trying to achieve? scramblebroke.hipnc Edited July 13, 2016 by f1480187 Quote Link to comment Share on other sites More sharing options...
tamagochy Posted July 13, 2016 Author Share Posted July 13, 2016 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. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted July 13, 2016 Share Posted July 13, 2016 How about this? box_transform.hipnc 1 Quote Link to comment Share on other sites More sharing options...
tamagochy Posted July 13, 2016 Author Share Posted July 13, 2016 Thanks, i take measure network and plug to my matrix transform tool and looks like it working)) Quote Link to comment Share on other sites More sharing options...
tamagochy Posted July 14, 2016 Author Share Posted July 14, 2016 I investigated this small vector problem, and found if i use lengh max compare and if calculation inside vop its somehow round small values to 0. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.