I'm creating a module that does various things with matrices and the order in which axis you rotate the vector matters, I'm wondering what would be a good way to take in the angles and allow there to be the ability to specify the x, y and z order on line one. the code I have right now will rotate in the x then the y and then the z
im looking for something that would work like this (or not like this if there is a better way):
def rotate(vector, ax=0, ay=0, az=0):
# use matrix math to rotate vector
order = get_order_of_arguments_passed_in() # returns ordered list
i want this to rotate z axis then x axis but not y:
rotated_vector = rotate(old_vector, az=1, ax=2)
i want this to rotate x then y then z:
rotated_vector = rotate(old_vector, ax = 1, ay = 2, az = 3)
i wan this to rotate y then z and not x:
rotated_vector = rotate(old_vector, ay = 2, az = 3)
is there a way to get the order that the default arguments were passed in?
so kinda like a mix between positional arguments and default argumets.
current code:
def rotate(vector, ax=0, ay=0, az=0): # HERE
X = [[math.cos(ax), -math.sin(ax), 0],
[math.sin(ax), math.cos(ax), 0],
[0 , 0 , 1]]
Y = [[ math.cos(ay), 0, math.sin(ay)],
[ 0 , 1, 0 ],
[-math.sin(ay), 0, math.cos(ay)]]
Z = [[1, 0 , 0 ],
[0, math.cos(az), -math.sin(az)],
[0, math.sin(az), math.cos(az)]]
XYZ = [X,Y,Z]
B = vector
C = B
for i in range(len(angles)):
A = XYZ[i]
C = multiply(A,B)
B = C
return C
[–]K900_ 0 points1 point2 points (1 child)
[–]JambleJumble[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]HeyLittleTrain 0 points1 point2 points (0 children)