yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #01502
Re: Quaternion question
> If want to play with Quaternions in python, I recommend very simple
> euclid module: http://partiallydisassembled.net/euclid.html
>
> Vaclav
>
Anton, I have attached modified scene.xml, which I have get from your
scene.xml
with Vaclav's euclid.py (Vaclav, thanks!) and typing the follow commands
in YADE console:
from euclid import *
O.load('scene.xml')
q1 = Quaternion.new_rotate_axis(pi/6, Vector3(0,1,0)) # rotate about Y
on pi/6 angles
q2 = Quaternion.new_rotate_axis(pi/2, Vector3(0,0,1)) # rotate about Z
on pi/2 angles
# now, YADE's se3 is [X,Y,Z, Ax,Ay,Az, a]
# where X,Y,Z is the body's position;
# Ax,Ay,Az is the rotation axis,
# a is the rotation angle.
# So, we...
o1 = q1.get_angle_axis() # get angle and axis for the first blue box
(rotation about Y)
o2 = (q2*q1).get_angle_axis() # get angle and axis for the second blue
box (first rotation about Y, after this rotation aboud Z)
# Then, we set the parameters,
O.bodies[1].phys['se3'] = [0,0,0, o1[1][0], o1[1][1], o1[1][2], o1[0]]
O.bodies[3].phys['se3'] = [0,0,0, o2[1][0], o2[1][1], o2[1][2], o2[0]]
<Yade>
<rootBody _className_="MetaBody" id="0" groupMask="1" isDynamic="0" clumpId="-1" tags="[author=Anton~Gladkyy~(anton@anton-laptop) isoTime=20090428T150205 id=20090428T150205p28444 description=]" dt="1e-08" currentIteration="0" simulationTime="0" stopAtIteration="0">
<physicalParameters _className_="ParticleParameters" se3="{0 0 0 1 0 0 0}" refSe3="{0 0 0 1 0 0 0}" blockedDOFs="0" mass="0" velocity="{0 0 0}" />
<geometricalModel />
<interactingGeometry _className_="MetaInteractingGeometry" diffuseColor="{0 0 1}" />
<boundingVolume _className_="AABB" diffuseColor="{0 0 1}" />
<engines size="10">
<engines _className_="PhysicalActionContainerReseter" label="" />
<engines _className_="BoundingVolumeMetaEngine" label="" functorNames="[[InteractingSphere AABB InteractingSphere2AABB] [InteractingBox AABB InteractingBox2AABB] [MetaInteractingGeometry AABB MetaInteractingGeometry2AABB]]">
<functorArguments size="3">
<functorArguments _className_="InteractingSphere2AABB" label="" aabbEnlargeFactor="1" />
<functorArguments _className_="InteractingBox2AABB" label="" />
<functorArguments _className_="MetaInteractingGeometry2AABB" label="" />
</functorArguments>
</engines>
<engines _className_="PersistentSAPCollider" label="" haveDistantTransient="0" />
<engines _className_="InteractionGeometryMetaEngine" label="" functorNames="[[InteractingSphere InteractingSphere InteractingSphere2InteractingSphere4ClosestFeatures] [InteractingBox InteractingSphere InteractingBox2InteractingSphere4ClosestFeatures] [InteractingBox InteractingBox InteractingBox2InteractingBox4ClosestFeatures]]">
<functorArguments size="3">
<functorArguments _className_="InteractingSphere2InteractingSphere4ClosestFeatures" label="" />
<functorArguments _className_="InteractingBox2InteractingSphere4ClosestFeatures" label="" />
<functorArguments _className_="InteractingBox2InteractingBox4ClosestFeatures" label="" />
</functorArguments>
</engines>
<engines _className_="FrictionLessElasticContactLaw" label="" />
<engines _className_="GravityEngine" label="" subscribedBodies="[]" gravity="{0 -9.8100000000000005 0}" />
<engines _className_="PhysicalActionDamper" label="" functorNames="[[ParticleParameters CundallNonViscousForceDamping] [RigidBodyParameters CundallNonViscousMomentumDamping]]">
<functorArguments size="2">
<functorArguments _className_="CundallNonViscousForceDamping" label="" damping="0.59999999999999998" />
<functorArguments _className_="CundallNonViscousMomentumDamping" label="" damping="0.90000000000000002" />
</functorArguments>
</engines>
<engines _className_="PhysicalActionApplier" label="" functorNames="[[ParticleParameters NewtonsForceLaw] [RigidBodyParameters NewtonsMomentumLaw]]">
<functorArguments size="2">
<functorArguments _className_="NewtonsForceLaw" label="" />
<functorArguments _className_="NewtonsMomentumLaw" label="" />
</functorArguments>
</engines>
<engines _className_="PhysicalParametersMetaEngine" label="" functorNames="[[ParticleParameters LeapFrogPositionIntegrator]]">
<functorArguments size="1">
<functorArguments _className_="LeapFrogPositionIntegrator" label="" />
</functorArguments>
</engines>
<engines _className_="PhysicalParametersMetaEngine" label="" functorNames="[[RigidBodyParameters LeapFrogOrientationIntegrator]]">
<functorArguments size="1">
<functorArguments _className_="LeapFrogOrientationIntegrator" label="" />
</functorArguments>
</engines>
</engines>
<initializers size="1">
<initializers _className_="BoundingVolumeMetaEngine" label="" functorNames="[[InteractingSphere AABB InteractingSphere2AABB] [InteractingBox AABB InteractingBox2AABB] [MetaInteractingGeometry AABB MetaInteractingGeometry2AABB]]">
<functorArguments size="3">
<functorArguments _className_="InteractingSphere2AABB" label="" aabbEnlargeFactor="1" />
<functorArguments _className_="InteractingBox2AABB" label="" />
<functorArguments _className_="MetaInteractingGeometry2AABB" label="" />
</functorArguments>
</initializers>
</initializers>
<bodies _className_="BodyRedirectionVector" >
<body size="4">
<body _className_="Body" id="0" groupMask="1" isDynamic="0" clumpId="-1">
<physicalParameters _className_="BodyMacroParameters" se3="{0 0 0 1 0 0 0}" refSe3="{0 0 0 1 0 0 0}" blockedDOFs="0" mass="2400" velocity="{0 0 0}" inertia="{400 400 400}" angularVelocity="{0 0 0}" young="30000000000" poisson="0.29999999999999999" frictionAngle="0.52359999999999995" />
<geometricalModel _className_="Box" visible="1" wire="0" shadowCaster="1" diffuseColor="{1 1 0.10000000000000001}" extents="{0.050000000000000003 0.5 1}" />
<interactingGeometry _className_="InteractingBox" diffuseColor="{0 0 0}" extents="{0.050000000000000003 0.5 1}" />
<boundingVolume _className_="AABB" diffuseColor="{0 0 0}" />
</body>
<body _className_="Body" id="1" groupMask="1" isDynamic="0" clumpId="-1">
<physicalParameters _className_="BodyMacroParameters" se3="{0 0 0 0 1 0 0.5235987755982987}" refSe3="{0 0 0 1 0 0 0}" blockedDOFs="0" mass="2400" velocity="{0 0 0}" inertia="{400 400 400}" angularVelocity="{0 0 0}" young="30000000000" poisson="0.29999999999999999" frictionAngle="0.52359999999999995" />
<geometricalModel _className_="Box" visible="1" wire="0" shadowCaster="1" diffuseColor="{0 0 1}" extents="{0.025000000000000001 0.59999999999999998 0.074999999999999997}" />
<interactingGeometry _className_="InteractingBox" diffuseColor="{0 0 0}" extents="{0.025000000000000001 0.59999999999999998 0.074999999999999997}" />
<boundingVolume _className_="AABB" diffuseColor="{0 0 0}" />
</body>
<body _className_="Body" id="2" groupMask="1" isDynamic="0" clumpId="-1">
<physicalParameters _className_="BodyMacroParameters" se3="{0 0 0 0 0 1 1.5708}" refSe3="{0 0 0 1 0 0 0}" blockedDOFs="0" mass="2400" velocity="{0 0 0}" inertia="{400 400 400}" angularVelocity="{0 0 0}" young="30000000000" poisson="0.29999999999999999" frictionAngle="0.52359999999999995" />
<geometricalModel _className_="Box" visible="1" wire="0" shadowCaster="1" diffuseColor="{1 1 0.10000000000000001}" extents="{0.050000000000000003 0.5 1}" />
<interactingGeometry _className_="InteractingBox" diffuseColor="{0 0 0}" extents="{0.050000000000000003 0.5 1}" />
<boundingVolume _className_="AABB" diffuseColor="{0 0 0}" />
</body>
<body _className_="Body" id="3" groupMask="1" isDynamic="0" clumpId="-1">
<physicalParameters _className_="BodyMacroParameters" se3="{0 0 0 -0.25056280708573159 0.25056280708573164 0.9351131265310294 1.637833824999823}" refSe3="{0 0 0 1 0 0 0}" blockedDOFs="0" mass="2400" velocity="{0 0 0}" inertia="{400 400 400}" angularVelocity="{0 0 0}" young="30000000000" poisson="0.29999999999999999" frictionAngle="0.52359999999999995" />
<geometricalModel _className_="Box" visible="1" wire="0" shadowCaster="1" diffuseColor="{0 0 1}" extents="{0.025000000000000001 0.59999999999999998 0.074999999999999997}" />
<interactingGeometry _className_="InteractingBox" diffuseColor="{0 0 0}" extents="{0.025000000000000001 0.59999999999999998 0.074999999999999997}" />
<boundingVolume _className_="AABB" diffuseColor="{0 0 0}" />
</body>
</body>
</bodies>
<transientInteractions _className_="InteractionVecSet" >
<interaction size="0" />
</transientInteractions>
<miscParams size="0" />
<dispParams size="0" />
</rootBody>
</Yade>
Follow ups
References