How to rotate the box

Asked by William

Hi,

Is there a command that rotates an object?

for example:

BOX = O.bodies.append(box((1,1,1),(1,1,1),...)

I want the 'BOX' to be rotated 45° around a line passing through its centroid and parallel to the z axis.

How can I implement this command?

Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
Last query:
Last reply:
Revision history for this message
Best Jan Stránský (honzik) said :
#1

Hello,

modify the box's orientation.
The proper usage depends on your actual needs, like if it is to 45° or by 45° etc.
E.g. something like:
###
box = utils.box((1,1,1),(1,1,1))
# note using utils.box to prevent name clash
# note using box as a result of utils.box, not O.bodies.append
boxID = O.bodies.append(box) # here the result is ID (number)
axis = (0,0,1) # parallel to the z axis
angle = 0.25 * pi # 45 degrees
box.state.ori = axis, angle
# or more verbose
box.state.ori = Quaternion(axis, angle)
###

Cheers
Jan

[1] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.State.ori

Revision history for this message
William (qfxx-123) said :
#2

Hi, Jan

Thanks for your help. The program doesn't work but I can't find out what's wrong.

#Wall constants
WDensity = 0
WFrictionAngle = 0.0
WPoissonRatio = 0.5
WYoung = 50e9
Mat = O.materials.append(FrictMat(young = WYoung, poisson = WPoissonRatio, frictionAngle = radians(WFrictionAngle), density = WDensity))

axis = (0,0,1)
angle = 0.25*pi
topbodylist = []
for i in range(10):
    box = utils.box((1+2*i,1,1),(sqrt(2)/2,sqrt(2)/2,sqrt(2)/2))
    box.mat=O.materials[Mat]
    box.state.ori = axis,angle
    boxid = O.bodies.append(box)
    topbodylist.append(boxid)
topwallclump = O.bodies.clump(topbodylist)

Revision history for this message
Jan Stránský (honzik) said :
#3

Please, open a new question for a new problem ([2], point 5)
Cheers
Jan

[2] https://www.yade-dem.org/wiki/Howtoask

Revision history for this message
William (qfxx-123) said :
#4

Thanks Jan Stránský, that solved my question.