← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3814: Add an opportunity to shift, scale and rotate imported polyhedrons

 

------------------------------------------------------------
revno: 3814
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Thu 2016-03-24 23:07:41 +0100
message:
  Add an opportunity to shift, scale and rotate imported polyhedrons
modified:
  py/ymport.py


--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'py/ymport.py'
--- py/ymport.py	2016-03-24 22:07:41 +0000
+++ py/ymport.py	2016-03-24 22:07:41 +0000
@@ -447,12 +447,13 @@
 	f.close()
 	return tetras
 
-def textPolyhedra(fileName,material,shift=Vector3.Zero,scale=1.0,**kw):
+def textPolyhedra(fileName,material,shift=Vector3.Zero,scale=1.0,orientation=Quaternion((0,1,0),0.0),**kw):
 	"""Load polyhedra from a text file.
 	
 	:param str filename: file name
 	:param [float,float,float] shift: [X,Y,Z] parameter moves the specimen.
 	:param float scale: factor scales the given data.
+	:param quaternion orientation:  orientation of the imported polyhedra
 	:param \*\*kw: (unused keyword arguments) is passed to :yref:`yade.polyhedra_utils.polyhedra`
 	:returns: list of polyhedras.
 
@@ -479,7 +480,7 @@
 			i+=1
 			for d in range(verts):
 				dataV = lines[i].split()
-				pos = Vector3(float(dataV[0]),float(dataV[1]),float(dataV[2]))
+				pos = orientation*Vector3(float(dataV[0])*scale,float(dataV[1])*scale,float(dataV[2])*scale)+shift
 				vertLoad.append(pos)
 				i+=1
 			polR = polyhedra_utils.polyhedra(material=material,v=vertLoad,**kw)