konstantin magnus Posted April 29, 2018 Share Posted April 29, 2018 (edited) I am currently using cross products and matrix transformations to replicate points in circles that are oriented by normals. 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 April 29, 2018 by konstantin magnus images Quote Link to comment Share on other sites More sharing options...
animatrix Posted April 30, 2018 Share Posted April 30, 2018 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); } 1 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted April 30, 2018 Author Share Posted April 30, 2018 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! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.