# How to rotate the box

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:
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
Last query:
 Revision history for this message Jan Stránský (honzik) said on 2022-04-19: #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

 Revision history for this message William (qfxx-123) said on 2022-04-19: #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 on 2022-04-19: #3

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

 Revision history for this message William (qfxx-123) said on 2022-04-19: #4

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