Home Forums Nazca How to draw a triangle

Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5397
    Wanshu
    Participant

    Dear Nazca team,

     

    I would like to draw a triangle with knowing a length and two angles.

    Within the geometries module, I saw rectangle, tetragon and trapezoid, but no triangle.

    BR,

    Wanshu

    #5400
    Ronald
    Keymaster

    Dear Wanshu,

    A straight forward way to define these kind of structures is to create a function that returns your custom polygon (list of points) and create a Polygon mask element from the list of points:

    from math import tan, radians
    import nazca as nd
    
    def triangle(length=10, angle=45):
        base = 2*length*tan(radians(0.5*angle))
        return [(0, 0.5*base), (0, -0.5*base), (length, 0)]
    
    tri = nd.Polygon(points=triangle(length=50, angle=30))
    tri.put(0)
    tri.put(0, 10, 45)
    
    nd.export_gds()

    Ronald

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.