I'm looking to calculate curl of a vector field to visualize vorticity within a velocity field.
Curl is stated as the cross product of the vector and the gradient or
From a houdini standpoint the gradient of a vector field is a 3x3matrix, so I don't see how you could possibly do a cross product of a matrix and a vector.
I think I'm missing a key point here since I can't find any information online about this kind of implementation.
Can any math gurus help me out here? I know its available in dop context so I don't think it would be too difficult to get together in sops(vex).
If I'm not mistaken you need a dot product of column vectors in your matrix with normalized x,y,z to get derivatives in x,y,z, which crossed with a velocity will give you a curl.
If you can do it in dops, there is the gas analysis dop will give you curl from a vector field. I have a good vorticity setup for flip laying around somewhere. I may turn it into a video tutorial this week just for kicks.
The curl of a vector field is just a vector field, not a matrix field. The second equation image on Wikipedia is probably what you're looking for. It defines curl directly in terms of derivatives, so there's no ambiguity about cross products: http://en.wikipedia.org/wiki/Curl_%28mathematics%29#Definition [en.wikipedia.org]
Symek, I think that is correct, I took the tensor-vector dot product of the gradient matrix and the normalized vector, then used that in a cross product with the vector, which first look appears to give a correct curl vector.
On a basic vortex velocity field it looks correct, but I need to check it out on a more complex field.
The VolumeAnalyis SOP should really have an option to calculate the curl, but in the meantime you can compute the gradient of each velocity component and calculate the curl by hand in VOPs (thereby doing a little extra work: nine derivatives instead of the six minimally required).
See attached for an example of computing the curl of a FLIP sim (and turn on the curl attribute visualization).
johner The VolumeAnalyis SOP should really have an option to calculate the curl, but in the meantime you can compute the gradient of each velocity component and calculate the curl by hand in VOPs (thereby doing a little extra work: nine derivatives instead of the six minimally required).
See attached for an example of computing the curl of a FLIP sim (and turn on the curl attribute visualization).
I was shown a similar solution which is correctly theoretically, but if you compare it against the dop computed curl they don't even look similar.
I ran a 2D smoke sim (xz axis) to compare. Curl vectors of a 2d field should all point along one axis (y axis). The dop computed curl does this but none of the sop solutions do.
icarus551 I was shown a similar solution which is correctly theoretically, but if you compare it against the dop computed curl they don't even look similar.
I ran a 2D smoke sim (xz axis) to compare. Curl vectors of a 2d field should all point along one axis (y axis). The dop computed curl does this but none of the sop solutions do.
Hmm, I'm not seeing much discrepancy. The attached 2d smoke test creates a curl attribute from both a DOP GasAnalysis-generated field, and the SOP solution. The values aren't identical, but are very close. Switch the smoke sim to 3d and the values are still very close.