Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into pr-fix-for-animat…
Browse files Browse the repository at this point in the history
…ion-autoreload
  • Loading branch information
damienmarchal committed Apr 1, 2022
2 parents 26de644 + 2b41d7f commit 9419556
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 26 deletions.
23 changes: 3 additions & 20 deletions python3/src/splib3/numerics/quat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from math import sin, cos, pi
from quat import *

class Quat_test(unittest.TestCase):

class Quat_test(unittest.TestCase):

def test_equal(self):
q1 = Quat()
Expand All @@ -14,7 +14,6 @@ def test_equal(self):
self.assertEqual(q1,[0.,0.,0.,1.])
self.assertNotEqual(q1,[0.707,0.,0.,0.707])


def test_constructors(self):
q = Quat()
self.assertEqual(q,[0.,0.,0.,1.])
Expand All @@ -25,48 +24,39 @@ def test_constructors(self):
q = Quat([0.707,0.,0.,0.707])
self.assertEqual(q,[0.707,0.,0.,0.707])


## PUBLICS METHODS

# PUBLICS METHODS

def test_getNorm(self):
q = Quat()
self.assertEqual(q.getNorm(), 1.)


def test_normalize(self):
q = Quat(1.,0.,2.,2.)
q.normalize()
self.assertEqual(q, [1./3.,0.,2./3.,2./3.])


def test_realPart(self):
q = Quat()
self.assertEqual(q.getRe(), 1.)


def test_imaginaryPart(self):
q = Quat(1.,2.,3.,4.)
self.assertEqual(q.getIm()[0], 1.)
self.assertEqual(q.getIm()[1], 2.)
self.assertEqual(q.getIm()[2], 3.)


def test_flip(self):
q = Quat(0.707,0.,0.,-0.707)
q.flip()
self.assertEqual(q, [-0.707,0.,0.,0.707])



def test_conjugate(self):
q = Quat()
self.assertEqual(q.getConjugate(), q)

q = Quat(0.5,0.5,0.5,0.5)
self.assertEqual(q.getConjugate(), [-0.5,-0.5,-0.5,0.5])


def test_getInverse(self):
q = Quat()
self.assertEqual(q.getInverse(), q)
Expand All @@ -77,7 +67,6 @@ def test_getInverse(self):
q = Quat(1.,1.,1.,1.)
self.assertEqual(q.getInverse(), [-0.25,-0.25,-0.25,0.25])


def test_getAxisAngle(self):
q = Quat.createFromAxisAngle([1.,0.,0.],pi/3.)
results = q.getAxisAngle()
Expand All @@ -86,23 +75,19 @@ def test_getAxisAngle(self):
self.assertEqual(results[0][2], 0.)
self.assertAlmostEqual(results[1], pi/3.)


def test_getEulerAngles(self):
q = Quat.createFromEuler([-pi/4.,0.,0.])
e = q.getEulerAngles()
self.assertAlmostEqual(e[0], -pi/4.)
self.assertEqual(e[1], 0.)
self.assertEqual(e[2], 0.)


## STATIC METHODS

# STATIC METHODS

def test_createFromAxisAngle(self):
q = Quat.createFromAxisAngle([1.,0.,0.],pi/2.)
self.assertEqual(q, [sin(pi/4.),0.,0.,cos(pi/4.)])


def test_createFromEuler(self):
q = Quat.createFromEuler([pi/2.,0.,0.])
self.assertEqual(q, [sin(pi/4.),0.,0.,cos(pi/4.)])
Expand All @@ -113,7 +98,6 @@ def test_createFromEuler(self):
q = Quat.createFromEuler([0.,pi/2.,0.],"syxz")
self.assertEqual(q, [sin(pi/4.),0.,0.,cos(pi/4.)])


def test_createFromEuler_against_rotateFromQuat(self):
q1 = Quat.createFromEuler([pi/2.,-pi/2.,0.],"rxyz")
q2 = Quat.createFromEuler([pi/2.,0.,0.],"sxyz")
Expand All @@ -135,7 +119,6 @@ def test_createFromEuler_against_rotateFromQuat(self):
q2.rotateFromQuat(q4)
self.assertEqual(q1,q2)


def test_rotateFromEuler(self):
q = Quat.createFromAxisAngle([1., 0., 0.], pi/2.)
q.rotateFromEuler([0.,-pi/2.,0.])
Expand Down
2 changes: 1 addition & 1 deletion python3/src/stlib3/physics/collision/collision.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def loaderFor(name):
if name.endswith(".obj"):
return "MeshObjLoader"
return "MeshOBJLoader"
elif name.endswith(".stl"):
return "MeshSTLLoader"
elif name.endswith(".vtk"):
Expand Down
2 changes: 1 addition & 1 deletion python3/src/stlib3/physics/mixedmaterial/rigidification.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def mfilter(si, ai, pts):
sourceObject.removeObject(sourceObject.solver)
if "integration" in sourceObject.objects:
sourceObject.removeObject(sourceObject.integration)
if "correction" in sourceObject:
if "correction" in sourceObject.objects:
sourceObject.removeObject(sourceObject.correction)

sourceObject.addObject("SubsetMultiMapping", name="mapping", template="Vec3,Vec3",
Expand Down
2 changes: 1 addition & 1 deletion python3/src/stlib3/physics/rigid/RigidObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def RigidObject(name="RigidObject",
def addCollisionModel(inputMesh=surfaceMeshFileName):
objectCollis = object.addChild('collision')
objectCollis.addObject('RequiredPlugin', name='SofaMeshCollision')
objectCollis.addObject('MeshObjLoader', name="loader",
objectCollis.addObject('MeshOBJLoader', name="loader",
filename=inputMesh, triangulate=True,
scale=uniformScale)

Expand Down
2 changes: 1 addition & 1 deletion python3/src/stlib3/scene/contactheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def ContactHeader(applyTo, alarmDistance, contactDistance, frictionCoef=0.0):
applyTo.addObject('BVHNarrowPhase')

applyTo.addObject('RuleBasedContactManager', responseParams="mu="+str(frictionCoef),
name='Response', response='FrictionContact')
name='Response', response='FrictionContactConstraint')
applyTo.addObject('LocalMinDistance',
alarmDistance=alarmDistance, contactDistance=contactDistance,
angleCone=0.01)
Expand Down
3 changes: 2 additions & 1 deletion python3/src/stlib3/scene/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ def addSettings(plugins=plugins, repositoryPaths=repositoryPaths):

root.gravity.value = gravity
root.dt.value = dt
root.addObject('VisualStyle')
root.addMainHeader = addMainHeader
root.addSettings = addSettings
root.addSolver = addDefaultSolver
root.addContact = addContactHeader
root.addModelling = addModelling
root.addSimulation = addSimulation

return root


Expand Down
2 changes: 1 addition & 1 deletion python3/src/stlib3/visuals/visualmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def init(self):
if path.endswith('.stl'):
self.addObject('MeshSTLLoader', name='loader',filename=path)
elif path.endswith('.obj'):
self.addObject('MeshObjLoader', name='loader',filename=path)
self.addObject('MeshOBJLoader', name='loader',filename=path)
else:
print("Extension not handled in STLIB/python3/stlib3/visuals for file: "+str(path))

Expand Down

0 comments on commit 9419556

Please sign in to comment.