Procedural implementation of EditSop's "Align Handle: Component" ?

   2311   2   1
User Avatar
Member
10 posts
Joined: May 2017
Offline
By EditSop's “Align Handle: Component”, we can scale one primitive along component direction like below image.






But I would like to scale many primitives along their component directions.
so procedural implementation is required.


I think I can do it if I scale it in Tangent Vector Space, and I wrote code.

vector T = prim(0, "Tangent",   pointprims(0, @ptnum)[0]);
vector N = prim(0, "N",         pointprims(0, @ptnum)[0]);
vector B = prim(0, "BiTangent", pointprims(0, @ptnum)[0]);

vector R0 = set(T[0], N[0], B[0]);
vector R1 = set(T[1], N[1], B[1]);
vector R2 = set(T[2], N[2], B[2]);

matrix3 A =  set(R0, R1, R2);
matrix3 AI = invert(A);

// scale shape in the "Tangent Vector Space" whose basis is Tangent, Normal, BiTangent
v@Pdash = @P * AI;
@Pdash[0] = @Pdash[0] * ch("./parmx");
@Pdash[1] = @Pdash[1] * ch("./parmy");
@Pdash[2] = @Pdash[2] * ch("./parmz");

// find result in the coordinate system whose basis is X:{1,0,0} Y:{0,1,0} Z:{0,0,1}
@P = @Pdash * A; 


But the result of this is not what I want because it is far from EditSop's result.
You can see it in my hipnc file. please see the link at the bottom of post.

Perhaps the problem is that I can't understand how EditSop's “Align Handle: Component” decide each handle direction.


Could you help me how to implement procedurally EditSop's “Align Handle: Component”?
Edited by onmk2 - June 1, 2019 18:20:46

Attachments:
coordinate_change.hipnc (136.0 KB)
01-06-2019 13-45-09.png (161.3 KB)
01-06-2019 13-45-17.png (223.3 KB)

User Avatar
Member
10 posts
Joined: May 2017
Offline
I made a mistake in calc matrix, it must be not @P*AI, but AI*@P.

but the problem remains. How Houdini decide handle direction of EditSop?
please see scale_tangent_and_normal.hipnc.

vector T = prim(0, "Tangent",   pointprims(0, @ptnum)[0]);
vector N = prim(0, "N",         pointprims(0, @ptnum)[0]);
vector B = prim(0, "BiTangent", pointprims(0, @ptnum)[0]);

vector R0 = set(T[0], N[0], B[0]);
vector R1 = set(T[1], N[1], B[1]);
vector R2 = set(T[2], N[2], B[2]);

matrix3 A =  set(R0, R1, R2);
matrix3 AI = invert(A);


// scale shape in the coordinate system whose basis is Tangent, Normal, BiTangent
v@Pdash = AI * @P;
@Pdash[0] = @Pdash[0] * ch("./parmx");
@Pdash[1] = @Pdash[1] * ch("./parmy");
@Pdash[2] = @Pdash[2] * ch("./parmz");


// find result in the coordinate system whose basis is X:{1,0,0} Y:{0,1,0} Z:{0,0,1}
@P = A * @Pdash;  
Edited by onmk2 - June 4, 2019 21:26:27

Attachments:
scale_tangent_and_normal.hipnc (119.5 KB)

User Avatar
Member
10 posts
Joined: May 2017
Offline
I found that I can use Edit Sop > Transform parameter > Local Frame > Component.

https://www.sidefx.com/docs/houdini/nodes/sop/edit.html#parameters [www.sidefx.com]
  • Quick Links