vector transformation in spherical and Cartesian coordinates

Hello everyone,

Here I have a vector array v = (v1, v2, v3), which is described in spherical coordinate, and I want to transfer it to Cartesian coordinate. Using the following relation,

image

I type in the calculator filter (name it vel):
(v1sin(coordsY)cos(coordsZ) + v2cos(coordsY)cos(coordsZ) - v3sin(coordsZ))iHat + (v1sin(coordsY)sin(coordsZ) + v2cos(coordsY)sin(coordsZ) + v3cos(coordsZ))jHat + (v1cos(coordsY) - v2sin(coordsY))*kHat

where (coordsX, coordsY, coordsZ) = (r, θ, φ), and (v1, v2, v3) = (v_r, v_theta, v_phi), as all the data are described in spherical coordinate. However, an error message pops out:
‘’’
ERROR: In /Users/kitware/dashboards/buildbot-slave/8275bd07/build/superbuild/paraview/src/VTK/Common/Misc/vtkFunctionParser.cxx, line 1244
vtkFunctionParser (0x7fee1fbd0e50): Syntax error: expecting a variable name; see position 10

ERROR: In /Users/kitware/dashboards/buildbot-slave/8275bd07/build/superbuild/paraview/src/VTK/Common/Misc/vtkFunctionParser.cxx, line 1244
vtkFunctionParser (0x7fee1fbd0e50): Syntax error: expecting a variable name; see position 10

Warning: In /Users/kitware/dashboards/buildbot-slave/8275bd07/build/superbuild/paraview/src/VTK/Filters/Core/vtkArrayCalculator.cxx, line 405
vtkPVArrayCalculator (0x7fee18f2e950): An error occurred when parsing the calculator’s function. See previous errors.
‘’’

I guess the problem is my data is cell data but coordsXYZ are all point data and cannot be mix. Can anyone help me about this issue? Thank you so much

–Yunlin

It looks like you forgot the multiply symbol in your equations. It should be (unless I also forgot one of the multiplication signs):
(v1sin(coordsY)cos(coordsZ) + v2cos(coordsY)cos(coordsZ) - v3sin(coordsZ))iHat + (v1sin(coordsY)sin(coordsZ) + v2cos(coordsY)sin(coordsZ) + v3cos(coordsZ))jHat + (v1cos(coordsY) - v2sin(coordsY))*kHat

Hi Andy,

I have typed the multiply symbol in the calculator filter. I think it is just in this forum the * symbol is hidden automatically.

Sorry, I should have read your email closer. Yes, you cannot mix point data arrays and cell data arrays in the calculator filter. The reason for this is that there’s no real correspondence between a point data value (or coordinate value in your case) and a cell data value index-wise. You can try using the Cell Data To Point Data Filter to transfer your cell data to point data and then the Calculator filter should give you something reasonable.

Thank you so much Andy, it works!