Skip to content

Commit

Permalink
[splib3/numerics] fixes case with no rotation given
Browse files Browse the repository at this point in the history
  • Loading branch information
EulalieCoevoet committed Jan 8, 2024
1 parent 41de3a7 commit 46db16e
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions python3/src/splib3/numerics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,35 @@ def to_radians(v):
return p
return v * pi * 2.0 / 360.0


def TRS_to_matrix(translation, rotation=None, scale=None, eulerRotation=None):
t = numpy.identity(4)
s = numpy.identity(4)
if eulerRotation != None:
q = Quat.createFromEuler(eulerRotation,inDegree=True)
else:
q = Quat(rotation)

if scale == None:
scale = [1.0,1.0,1.0]
if eulerRotation is not None:
q = Quat.createFromEuler(eulerRotation, inDegree=True)
elif rotation is not None:
q = Quat(rotation)
else:
q = Quat() # default [0, 0, 0, 1] quaternion

if scale is None:
scale = [1.0, 1.0, 1.0]

r = q.getMatrix()
rr = numpy.identity(4)
rr[0:3, 0:3] = r

t[0,3]=translation[0]
t[1,3]=translation[1]
t[2,3]=translation[2]
t[0, 3] = translation[0]
t[1, 3] = translation[1]
t[2, 3] = translation[2]

s[0, 0] = scale[0]
s[1, 1] = scale[1]
s[2, 2] = scale[2]

s[0,0]=scale[0]
s[1,1]=scale[1]
s[2,2]=scale[2]
return numpy.matmul(numpy.matmul(t, rr), s)

return numpy.matmul( numpy.matmul(t,rr), s )

def transformPositions(position, translation=[0.0,0.0,0.0], rotation=[0.0,0.0,0.0,1.0], eulerRotation=None, scale=[1.0,1.0,1.0]):

Expand Down

0 comments on commit 46db16e

Please sign in to comment.