Jump to content
konstantin magnus

Replicating circular points around normals

Recommended Posts

Posted (edited)

I am currently using cross products and matrix transformations to replicate points in circles that are oriented by normals.

replicate_points_around_normals_2.jpg.5d10b49a4c04dbd2ea07f34877e31990.jpgreplicate_points_around_normals.jpg.3ee5e8621b6929323a7b6a5363e46332.jpg

Are there any more straight forward ways to achieve this with VEX?

int points = chi('points');
float scale = 0.02;

vector up = {0, 1, 0};

for(int i = 0; i < points; i++){
    vector dir = normalize( cross(@N, up) );
    float amount = (i / float(points)) * $PI * 2;
    matrix m = ident();
    rotate(m, amount, @N);
    dir *= m;
    dir *= scale;
    int pt = addpoint(0, @P + dir);
}

 

Edited by konstantin magnus
images

Share this post


Link to post
Share on other sites

You can simplify it a bit using sample_circle_uniform and dihedral functions:

for(int i = 0; i < points; i++){
  float u = i / float(points);
  vector p = sample_circle_uniform(set(u, ch("r")));
  matrix m = dihedral({0,1,0}, @N);
  addpoint(0, @P + set(p.x, 0, p.y) * m);
}

 

  • Like 1

Share this post


Link to post
Share on other sites

So you 

  • create "flat" circle coordinates based on u with sample_circle_uniform() and scale them immediately by adding a second vector component to "u" as a radius argument,
  • calculate a rotation matrix based on the difference between an up vector and the point´s normal with dihedral(), and
  • transpose the 2D circle coordinates to a vector3, multiplying it by the rotation matrix and adding that to the current point position.

Now that´s clever!

  • Like 1

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

×