Jump to content

# 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.

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

##### 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);
}```

• 1

#### Share this 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!

• 1

## 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

×
• Donations

• Leaderboard