# 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

perpenticular_tangent.hipnc

##### 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 on other sites

here's a simple one ...

hth. petz

##### 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 ?

Edited by Entropy

##### 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 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 on other sites
Posted (edited)

It is another way.

However, this method does not work unless it has a structure that can be converted to a mesh.

Edited by satoru

##### Share on other sites
Posted (edited)

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

Edited by Entropy

##### Share on other sites

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.

##### Share on other sites

Thank you very much @satoru

Doumo arigatou gozaimasu

## 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