Jump to content

Orienting Copy within For-Loop


mikenon

Recommended Posts

Ive been banging my head against this for a few hours. I am building a set of S-shaped fence pickets within a for-loop. I would like to orient each picket to be aligned with the tangent of the curve path. The problem is that the picket itself is built within the for-loop so that each picket can be customized. So I need to orient the pickets after they have been built. I will eventually need to make some fairly complicated customizations for each picket instance, so I don't want to get rid of the structure of building the picket within the for-loop. 

I have gotten as far as storing the tangent of the curve path (tangentu) and the x,z coordinate of each picket's pivot point (pcx,pcz). But I cannot figure how to use that information to rotate each picket around the pivot so that it is aligned with the curve. Or maybe there is a simpler way? HIPNC file attached.

Screen Shot 2016-06-09 at 2.21.33 PM.png

exp2.hipnc

Link to comment
Share on other sites

Well, I solved my own problem. For anyone curious, the key was using the stored pcx, pcz and tangentu attributes. A little attribute point wrangle did the trick:

float angleT = -$PI/2 + atan(v@tangentu.x,v@tangentu.z);
vector pivot = set(@pcx,@P.y,@pcz);
float dist = distance(@P,pivot);
float r = atan(@P.x-pivot.x,@P.z-pivot.z);

@P.x = pivot.x + dist*sin(r+angleT);
@P.z = pivot.z + dist*cos(r+angleT);

  • Like 1
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...