Jump to content

Replicating circular points around normals


konstantin magnus

Recommended Posts

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
Link to comment
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
Link to comment
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
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...