- #1
antennaist
- 2
- 0
I have a uniform grid of data in spherical coordinates. e.g. theta = 0, 1, 2, ... 180 and phi = 0, 1, 2, ... 359 which forms a 2D matrix. I wish to rotate these points around a cartesian axis (x, y, z-axis) by some angle alpha. To accomplish this I currently do the following:
1. Convert to cartesian coordinates
2. Multiply by rotation matrix
3. Convert back to spherical coordinates
4. Non-uniform interpolation over the original uniform grid
The problem with this is two-fold:
1. The non-uniform interpolation of step 4 e.g. using MATLAB's griddata function is slow. For instance a non-uniform interpolation of a 360 x 181 matrix on my machine takes about 1.8 seconds.
2. Most non-uniform interpolation functions such as MATLAB's griddata are not in spherical coordinates which means that convex hull typically does not contain theta = 0 and 180 or phi = 0 or 360. I currently get around this by seeding the non-uniform data with points outside of phi = 0,360 and theta = 0,180 which is both inaccurate and adds to the computation time.
My main problem is speed. It's simply too slow for what I need. It seems like this would be a common problem that must have some elegant solution that I have not heard of. My question is simply:
Is there a better way to do this?
1. Convert to cartesian coordinates
2. Multiply by rotation matrix
3. Convert back to spherical coordinates
4. Non-uniform interpolation over the original uniform grid
The problem with this is two-fold:
1. The non-uniform interpolation of step 4 e.g. using MATLAB's griddata function is slow. For instance a non-uniform interpolation of a 360 x 181 matrix on my machine takes about 1.8 seconds.
2. Most non-uniform interpolation functions such as MATLAB's griddata are not in spherical coordinates which means that convex hull typically does not contain theta = 0 and 180 or phi = 0 or 360. I currently get around this by seeding the non-uniform data with points outside of phi = 0,360 and theta = 0,180 which is both inaccurate and adds to the computation time.
My main problem is speed. It's simply too slow for what I need. It seems like this would be a common problem that must have some elegant solution that I have not heard of. My question is simply:
Is there a better way to do this?