Hello
since my script surrounding rs.Pointarraytransform(x, rs.XformMirror()) does not work the way I would like it to, it would be amazing if you can point out the mistake I made. Ive tryed for days, but could not find a solution. Thanks!
The coordinates of a tetrahedon, need to be mirrored at every cornerpoint using those of its sides, that are meeting in the cornerpoint as mirrorplane defining normals.
For context, the tetrahedon fits into a rectangle of sidelength( 1,1,1 ), and the final aim is to write a script for conways game of life, in which the existance of an instance depends on its neighbours.
By comparing the coordinates I plan to identify neighboring tetrahedon-cells.
Using rs.InsertBlock(Tetrahedon, xformmirror()), a mirrored tetrahedon is inserted flawlessly.
But the way I use rs.pointarraytransform() , it does not seem to work. Where did I make a mistake?
Thank you very much and with best regards,
Aero
This is my code:
import rhinoscriptsyntax as rs
rs.DeleteObjects(rs.AllObjects())
##Block
coordinates = [ (0,0,0), (1,0,1), (1,1,0), (0,1,1)]
#draw the tetrahedon:
lines = []
for entry in coordinates:
aktive_Postition = coordinates.index(entry)
for counter in range(len(coordinates)):
if counter > aktive_Postition: #makes every combination of ccordinates. no dublicates with counter
line = rs.VectorCreate(entry, coordinates[counter])
if rs.VectorLength( line ) >= 2**0.5: lines.append([entry, coordinates[counter]]) #2**0.5 = sidelength of tetrahedon
rs.AddBlock((rs.AddLine( pair[0], pair[1] ) for pair in lines), (0,0,0), name="cell")
for p in coordinates:
print "--> {}: ".format(coordinates.index(p)), p
for pair in lines:
if p in pair:
#here starts the problem:
print "!!!{} contains point!!!".format(pair)
mirror = rs.XformMirror( p, rs.VectorCreate(pair[1], pair[0] ))
mc = mirrored_coordinates = list(rs.PointArrayTransform(coordinates, mirror))
for (a,b) in zip( coordinates, mc): print( a, "mirrored {}".format(b))
#print "mirrored", mc
#V1: - no problems
#rs.InsertBlock2("cell", mirror)
#V2: - not working properly:
#rs.InsertBlock("cell", rs.SortPoints( mc, order=4)[0])
#"""V3 drawing the tetrahedon form mirrored_coorinates:
for point in mc:
aktive_Postition = mc.index(point)
for counter in range(len(mc)):
if counter > aktive_Postition:
laen = rs.VectorLength( rs.VectorCreate(point, mc[counter] ))
if laen >= 2**0.5:
rs.AddLine( point, mc[counter])
#"""