Rotation of a yarn

General discussion about TexGen.

Moderators: Martin, Developers

Post Reply
cberkley
Posts: 2
Joined: Wed Feb 08, 2012 5:20 pm

Rotation of a yarn

Post by cberkley »

Hi
I am using TexGen to create unit cell weaves for my 3rd year project. I am creating a python script for layered weaves and exporting these to test the macro structural properties.

I am having some problems with the rotate function Rotate (WXYZ (), XYZ ()). I believe the second part is the point at which the rotation occurs but what is the first bit?

I would appreciate some help on this. I am new to TexGen and coding in general

Chris
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: Rotation of a yarn

Post by louisepb »

Hi Chris,

The WXYZ is a quaternion ( see here: http://en.wikipedia.org/wiki/Quaternion ... l_rotation )

The documentation for creating a quaternion from either a normalised axis and angle, a new coordinate system or euler angles is here: http://texgen.sourceforge.net/api/struc ... x_y_z.html. You need to decide how best to specify your rotation, create your quaternion from this and then use it in the Rotate function.

Hope that helps,

Louise
cberkley
Posts: 2
Joined: Wed Feb 08, 2012 5:20 pm

Re: Rotation of a yarn

Post by cberkley »

Louise
Thank you for your help but it would seem I still have a problem

Code: Select all

Angle=math.radians(12)
Yarn = CYarn(Textile.GetYarn(0))
Yarn.Rotate(WXYZ(XYZ, double Angle), XYZ(1,0,0.225))
Yarn.Translate(XYZ(0, 0, 0.3))
Textile.AddYarn(Yarn)
This is the code I wrote however it produces an error
File \2d weave.py", line 13
Yarn.Rotate(WXYZ(XYZ, double Angle), XYZ(1,0,0.225))
^
SyntaxError: invalid syntax
with the triangle under Angle
Apologies for bugging you
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: Rotation of a yarn

Post by louisepb »

Hi Chris,

You need to take the double out of the Rotate call. You also need to define the XYZ either in the same way as you've done the second one in the call or by defining an XYZ variable and using that.

Louise
Post Reply