### Rotate Points around a curve

352   2   0
Member
303 posts
Joined: July 2012
Offline
Hi there, Im struggling with something that should hopefully not be too difficult for someone with more vex knowledge. Ive uploaded a hip of a simple scene, where I have points around a curve. I want the points to orbit around the curve, but maintain their distance. A pop curve force wasn't really working out, and I can't use a pop axis force, so I assumed vex would be the best answer. Any help would be appreciated!

Attachments:
Points_Rot_Around_Curve_01.hiplc (338.5 KB)

Member
3787 posts
Joined: Feb. 2012
Online
Hi,

If you generate tangent vectors for your curve, you can do something like this:

```int primhit = -1;
vector uvhit = 0;

xyzdist ( 1, @P, primhit, uvhit );
vector p = primuv ( 1, "P", primhit, uvhit );
vector t = primuv ( 1, "N", primhit, uvhit );

float r = fit01 ( rand ( @ptnum ), 0.7, 1.5 );
float angle = @Time * ch("speed") * pow ( r, 2 );

matrix3 m = ident ( );
rotate ( m, angle, t );
vector pnew = ( @P - p ) * m + p;

@P = pnew;
```