To draw lines between points P1 and P2 you can use line ([(x1, y1), (x2, y2)]). But to know which point P1 to join to which point P2 you must:Either build your points in a logical way to have a method to join them.Or calculate the distances between all your points (900 points! 900*899/2 distances ?) ?) And keep only the points whose distance is equal to 1 (in approximate value of course). Which is frankly long even if you have a fast computer.That's why I suggested you go through Polyedron.
Le samedi 18 mai 2019 20:46:48 UTC+2, Grumby a écrit : > > Hello, > > You have to draw lines between your points. > A solution is to use polyhedron. For instance : > > hexa0 = polytopes.regular_polygon(6) > hexa1 = hexa0.translation([float(sqrt(3))/2,1.5]) > > g = Graphics() > > i = 0 > while i < 6: > j = 0 > while j < 4: > hexa00 = hexa0.translation([i*float(sqrt(3)),j*(3)]) > outline00 = hexa00.projection().render_outline_2d() > hexa11 = hexa1.translation([i*float(sqrt(3)),j*(3)]) > outline11 = hexa11.projection().render_outline_2d() > > g += outline00 + outline11 > > j += 1 > i += 1 > > g.show(aspect_ratio=1) > > > Le samedi 18 mai 2019 20:44:15 UTC+2, Grumby a écrit : >> >> >> >> Le vendredi 17 mai 2019 05:35:54 UTC+2, saad khalid a écrit : >>> >>> Hi everyone: >>> >>> I'm trying to using Sage's plot functionality to plot the honeycomb >>> lattice: >>> >>> https://sites.google.com/site/makingplots4scipurposes/_/rsrc/1456789513003/gnuplot-samples-of-2d-lattices/honeycomb.png >>> >>> Plotting the honeycomb lattice is slightly different from plotting a >>> simple (like a square) lattice, as each site is technically two points, >>> with a basis vector pointing from one point to the other within a single >>> site. So you take your two lattice vectors and start from some point and >>> generate all possible points from those lattice vectors. Then you go back >>> to your starting point, shift by the basis vector, and then generate all >>> possible points from there using the lattice vector, and then you add these >>> two sets of points together to get the honeycomb lattice. I've figured out >>> how to do it using points at the corner of each hexagon, like this: >>> list_plot(flatten([[a*vector([sqrt(3)/2,1/2]) + b*vector([sqrt(3)/2,-1/2 >>> ]) for a in (0..30)] for b in (0..30)] + [[a*vector([sqrt(3)/2,1/2]) + b >>> *vector([sqrt(3)/2,-1/2]) + vector([-1/sqrt(2),0]) for a in (0..30)] for >>> b in (0..30)])) >>> >>> However, I was hoping to do this with lines outlining the hexagons as >>> shown in the linked image. Would anyone know of a way to do this? Thanks! >>> >> -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/e794aa7d-36be-4a4e-8831-044159a22a75%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.