dlewin
1
hello everybody,
On one hand there is a tuple of coordinates :
on the other hand I have a fontion that want a Vec3 as input parameter
Line(Vec3(x1,y1,z1), Vec3(x2,y2,z2))
What is the way to traverse properly the tuple with the Line fonction like :
Line (1,1,1), (2,1,1) )
Line (2,1,1), (3,5,1) )
(the Z axe is always at 1)
dlewin
2
although this is a quite simple problem, (it seems you have tried everything before posting ) , it’s not so obvious .
This could be solved like this :
x1 = float(coord[i][0])
y1 = float(coord[i][1])
x2 = float(coord[i+1][0])
y2 = float(coord[i+1][1])
LineFonx(Vec3( x1,y1 ,1), Vec3( x2,y2,1) )
dlewin
3
hey that’s right,
exactly what I was looking for
thank you so much
enn0x
4
Another one, using Python list comprehension. The last two lines is where the magic happens, the first lines is just to make a standalone demo.
from pandac.PandaModules import Vec3
def YourLineFunction( v1, v2 ): print 'Line:', v1, v2
coords = [ (1,1), (2,1), (3,5) ]
vectors = [ Vec3( z=1, *p ) for p in coords ]
map( YourLineFunction, vectors[:-1], vectors[1:] )
enn0x