File:Beta-skeleton.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 450 × 450 pixels, file size: 78 KB)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

    Description
    English: Two β-skeletons of a set of 100 random points in a square. The heavy dark edges are the β-skeleton for β = 1.1, while the light dashed blue edges are the additional edges for β = 0.9.
    Date
    Source Own work
    Author David Eppstein
    SVG development
    InfoField
     The SVG code is valid.
     This trigonometry was created with Adobe Illustrator.

    Source code

    This image was created with the following Python source code and then recolored and converted to SVG in Adobe Illustrator.

    from pyx import canvas,path,color
    from math import *
    from random import seed,random
    seed(12345)
    
    npoints = 100
    radius = 0.05
    scale = 5
    beta1 = 1.1
    beta2 = 0.9
    theta1 = asin(1/beta1)
    theta2 = pi - asin(beta2)
    
    points = [(random()*scale,random()*scale) for i in range(npoints)]
    
    def dot(p,q,r):
        return sum((p[i]-r[i])*(q[i]-r[i]) for i in [0,1])
    
    def sharp(p,q):
        theta = None
        for r in points:
            if r not in [p,q]:
                prq = acos(dot(p,q,r) / (dot(p,p,r)*dot(q,q,r))**0.5)
                theta = max(theta,prq)
        return theta
    
    c = canvas.canvas()
     
    def edge1(p,q):
        c.stroke(path.line(p[0],p[1],q[0],q[1]),
                 [color.rgb.black])
    
    def edge2(p,q):
        c.stroke(path.line(p[0],p[1],q[0],q[1]),
                 [color.rgb.blue])
    
    def point(p):
        c.fill(path.circle(p[0],p[1],radius),[color.rgb.red])
    
    for p in points:
        for q in points:
            if p < q:
                theta = sharp(p,q)
                if theta < theta1:
                    edge1(p,q)
                elif theta < theta2:
                    edge2(p,q)
    
    for p in points:
        point(p)
    
    c.writePDFfile("Beta-skeleton")
    

    Licensing

    Public domain This work has been released into the public domain by its author, David Eppstein. This applies worldwide.
    In some countries this may not be legally possible; if so:
    David Eppstein grants anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

    Captions

    Add a one-line explanation of what this file represents

    Items portrayed in this file

    depicts

    19 February 2010

    image/svg+xml

    46602904f32f387c12a018868fce3fc20309533e

    79,414 byte

    450 pixel

    450 pixel

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current04:58, 20 February 2010Thumbnail for version as of 04:58, 20 February 2010450 × 450 (78 KB)wikimediacommons>David Eppstein{{Information |Description={{en|1=Two β-skeletons of a set of 100 random points in a square. The heavy black edges are the β-skeleton for β = 1.1, while the light dashed blue edges are the additional edges for β =&

    There are no pages that use this file.