# Calculate Curl on a grid sop using attrwrangle sop

## Recommended Posts

Hey guys

Ive been trying this for a while now, but i still am not able to solve it.

Other than converting a grid to a volume and running a volume analyse sop, how would one calculate curl of velocity on a grid sop using an attribute wrangle.

Ive setup a simple grid and ran it thru a pointvop in which ive just plugged in the output of a curl noise vop into v. Now i just want to calculate the curl of v using just the attribute wrangle using neighbours() vex function.
So far ive managed to calculate the gradient of each v component, but the rest of math i cannot translate to proper code.

Any ideas?

p.s. does anyone have resources how to move from math notations to code

Thanks

##### Share on other sites

You can use this VOP:

##### Share on other sites

Thanks Pusat

But that vop relies on volumes and inside its just a simple volumegradient, like i mentioned, id like to find out how to do the same thing without using volumes and how the math would translate into code.

##### Share on other sites

In that case, I would probably use edge connectivity or point clouds and get the point with the maximum v.x, v.y, v.z separately from the current point, and then calculate a vector that goes from the current point to the point with the max value.

Then you can replace the gradient vectors with these vector values.

##### Share on other sites

Yeah i actually did exactly the same, the problem is i would get completely different results compared to a vdb analysis sops curl operator.

Thats why i thought i was doing something wrong math wise, or i just didnt understand the notation really well.

I just used the neighbours() vex command to extract the points sharing the same edge, and went to build a gradient for each v component. I got a 3x3 matrix with the gradient vector components in it, and did the same subtraction like in that example you sent, but it looked so different from volume curl, i couldnt figure out why.

##### Share on other sites

you get the curl if you take the cross product from your vector and gradient, if you want compute the gradient from a grid in vex,  you have a ode with 2 components x,y and you can compute the gradient for each component, but if you have 3 components and they depending from eachother like a vectorfield,  you can use a gradient descent (jacobian) algorithm it does the exact same thing what sensei pusat described to compute the partial deriative, to get the gradient for a vectorfield with x,y,z, its my understanding i can be wrong

Edited by deniz

##### Share on other sites

if you are talking about a tangent vector field than it´s fairly easy to calculate by basically summing up angles. if its not a tangent field it would be much harder to discretize but also wouldn´t make much sense anyhow ...

hth. petz

• 1

## Create an account

Register a new account