Issue
I am working with nd arrays which contain coordinate data for multiple contours in [x, y, z] space.
I am trying to add x, y, and z offsets to the lines based on other conditions. The offsets will be the same for any of the lines within the array.
Here is a sample array
arr= [[[0, 0, 0]
[0, 0, 0]]
[[0, 0, 0]
[0, 0, 0]]
[[0, 0, 0]
[0, 0, 0]]]
If I have xOffset = 1, and yOffset = 2, and zOffset = 0 how do I add it to the individal line it returns:
arr= [[[1, 2, 0]
[1, 2, 0]]
[[1, 2, 0]
[1, 2, 0]]
[[1, 2, 0]
[1, 2, 0]]]
I have tried using
arr[:][:][0] += xOffset
arr[:][:][1] += yOffset
arr[:][:][2] += zOffset
But it adds the offsets to every column, not just the x, y, z columns in the subarrays
Solution
You could try to create a temporary offset column as a 1D array and then add it into the corrected column, you should be able to do column arithmetic with numpy (It has been a moment since I've tried it myself)
This answer may also help you.
Doing arithmetic with python array columns
Answered By - Matthew S Giancola
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.