Jump to content
Entropy

Perpenticular World Space Tangent on Surface

Recommended Posts

Hello 
is there a more efficient way to calculate the world space tangent on a surface ?

the method i use in the attached file seems limited as it uses boolean sections and polyframe to transfer the tangent to the surface
any ideas on how to improve 


thanks in advance


 

perpenticular_tangent.hipnc

Share this post


Link to post
Share on other sites

Also i just noticed that there are problems with the initial direction of the tangents
after the boolean operation some curves have their tangent direction reversed

is there some easy way to clockwise all the curves ?

thanks

Share this post


Link to post
Share on other sites

that is ridiculously simple thanks a lot @petz

any idea why the boolean operation reverses randomly the curve direction 
even when the same object copy is used to intersect ?

i use various meshes not just planes to cut - intersect surfaces with the boolean operation 
and create the surface tangents perpendicular to the curves
but there are inconsistency with the extracted curves
is there any easy way to find those problematic curves and reverse them ?

thanks in advance
 

Edited by Entropy

Share this post


Link to post
Share on other sites

due to the use of "remove shared edges" in the divideSop you got always two coincident polygons for every section. you need to delete duplicates and then make sure the normals of remaining prims are pointing into the same direction.
instead, you could also set the output of the booleanSop to "seam" and check the curve direction based on point neighbours ...

hth.
petz

Share this post


Link to post
Share on other sites

i had no success determining whether or not a curve has its points ordered clockwise or anticlockwise
 

float sum = 0.0;
for (int i = 0; i < i@numpt; i++) {
   vector v1 = point(0,"P",i);
   vector v2 = point(0,"P",i+1) % i@numpt;
   sum += (v2.x - v1.x) * (v2.y + v1.y);// * (v2.z - v1.z);
}

setprimgroup (0, "reverse", @primnum, 0, "set");
                            
if(sum > 0){
  setprimgroup (0, "reverse", @primnum, 1, "set");
}

 

obviously it is not right the above solution is for a 2d curve
any idea for the 3d equivalent  ?
 

Edited by Entropy

Share this post


Link to post
Share on other sites

Hi satoru thanks for your reply
but unfortunately this is not working for my case
i uploaded a new file to illustrate the issue
i use polycut the result is the same as with boolean operations
the unshared  edges always produse two coincident polygons as petz said

 

perpenticular_tangent_polycut.hipnc

Edited by Entropy

Share this post


Link to post
Share on other sites
On 02/03/2018 at 2:17 PM, satoru said:

If it is a curve extracted from the surface, you can determine the direction with the inner product of the original N and the new N.

I am sorry if it is a misunderstanding.

perpenticular_tangent_polycut_sy.hipnc

Trying to have all complex curves network i have to deal with  be oriented properly to be able to use a signed distance to cut my mesh precisely without having to increase the mesh density, for this is need to orient my curves properllu.

To what i could see in your simple example, while the orientation of the close curves are not correct, the tangent vector are oriently not uniformly in the same consistent direction, like for the mouth . I try to sort but didn't solve , any idea?

 

@petz

 

image.thumb.png.ce826191a043d6b57058981434a3620d.png

Share this post


Link to post
Share on other sites

@vinyvince
Math- 2016/-Sarajevo /Jaroslav Cerni/Berlin/Math/
How you cut your Geo?
Can you Share some simple ex on Your exampel 
If its not for Rocket Science project that you do :P



int he = pointhedge(0,@ptnum);
vector nextP = attrib(0,'point','P',hedge_dstpoint(0,he));
vector edgeVector = nextP-@P;
if (he==-1){edgeVector={0,0,0};} // in case this is an end point
f@pscale = length(edgeVector);
v@tangent = normalize(edgeVector);
 
p@orient;

-------------------------------------------------
#include "math.h"
int n = npoints(0);
 
// first point orientation
vector xaxis = {1,0,0};
vector tangent = attrib(0,"point","tangent",0);
vector rotaxis = normalize(cross(xaxis,tangent));
float rotangle = acos(dot(xaxis,tangent));
vector4 Q = quaternion(rotangle,rotaxis);
setpointattrib(geoself(),"orient",0,Q);
 
// parallel transport
int currPoint = 0;
vector4 cumQ=Q;
do{
  int he = pointhedge(0,currPoint);
  int nextPoint = hedge_dstpoint(0,he);
  if (nextPoint==-1){break;}// in case this is the end point
  vector currTan = attrib(0,"point","tangent",currPoint);
  vector nextTan = attrib(0,"point","tangent",nextPoint);
  rotaxis = normalize(cross(currTan,nextTan));
  rotangle = acos(dot(currTan,nextTan));
  Q = quaternion(rotangle,rotaxis);
  cumQ = qmultiply(Q,cumQ);
  
  // optional: additional twist by PI/2 for interlocking rings
  vector4 R = quaternion(PI/1,nextTan);
  cumQ = qmultiply(R,cumQ);
  
  setpointattrib(geoself(),"orient",nextPoint,cumQ);
  currPoint = nextPoint;
}while(currPoint!=0);

 

frtd.jpg

fvg.jpg

Share this post


Link to post
Share on other sites

Oh my task for this studio is completed Tesan, i refused a couple of jobs, las t one yesterday as i need to rest a bit or i didn't feel exited :)

The example im using is the one used in this forum , just noticing the tangent orientation could go CW or CCW for the curves where the winding have been solved, after on some complex case, i have a bunch of 3d curves in space which will like to orient all in the same direction. in 2d space , you could use a circle or cyl mapping to order then and polyframe, but in 3d space, i haven't found out. Just looking at the I don't have the math.library,  What's
this line is supposed to do?

p@orient;

Share this post


Link to post
Share on other sites

This is an example of what i haven't fun with personally... Looks like mostly everyone is only considering Houdini for FX or scene assembly, a pity no?

sorry for the Opengl capture, no power or time to make a beautiful render here :)

No uv , only input is this glorious female mesh

 

________________________________________________________________

Vincent Thomas   (VFX and Art since 1998)
Senior Env and Lighting  artist & Houdini generalist & Creative Concepts

 http://fr.linkedin.com/in/vincentthomas

evengellion_babe_procedural_vince_captureOpenGL.gif

babe07.PNG

Edited by vinyvince

Share this post


Link to post
Share on other sites
56 minutes ago, vinyvince said:

What's
this line is supposed to do?

part of something that just having Fun on The Sun . Nice example  there you have ..
"post final prim count " ...on that mesh ..Just wonder :rolleyes:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×