파일:Closest pair of points.svg

문서 내용이 다른 언어로는 지원되지 않습니다.
위키백과, 우리 모두의 백과사전.

원본 파일(SVG 파일, 실제 크기 256 × 256 픽셀, 파일 크기: 1 KB)

파일 설명

설명
English: Closest pair of points shown in red.
날짜
출처 자작
저자 Qef
다른 버전 Bitmap version: file:ClosestPair.png

라이선스

Creative Commons CC-Zero 이 파일은 크리에이티브 커먼즈 CC0 1.0 보편적 퍼블릭 도메인 귀속에 따라 이용할 수 있습니다.
저작물에 본 권리증서를 첨부한 자는 법률에서 허용하는 범위 내에서 저작인접권 및 관련된 모든 권리들을 포함하여 저작권법에 따라 전 세계적으로 해당 저작물에 대해 자신이 갖는 일체의 권리를 포기함으로써 저작물을 퍼블릭 도메인으로 양도하였습니다. 저작권자의 허락을 구하지 않아도 이 저작물을 상업적인 목적을 포함하여 모든 목적으로 복제, 수정·변경, 배포, 공연·실연할 수 있습니다.

Source code

The SVG was generated by running the Lua program given below. It deliberately fails if the closest points would be overlapping in the image, because that would be confusing.

local WD, HT, NUM_POINTS = 256, 256, 16
local COLOR = { normal = '#000', closest = '#f00' }
local RADIUS = 5

math.randomseed(os.time())
local P = {}
for _ = 1, NUM_POINTS do
    P[#P+1] = { x = RADIUS + (WD - 2*RADIUS) * math.random(),
                y = RADIUS + (HT - 2*RADIUS) * math.random() }
end

-- Find closest pair, using naive algorithm.
local closest_a, closest_b
local min_dist
for i, p in ipairs(P) do
    for j, q in ipairs(P) do
        if i ~= j then
            local dist = math.sqrt((p.x - q.x)^2 + (p.y - q.y)^2)
            if not min_dist or dist < min_dist then
                min_dist = dist
                closest_a, closest_b = i, j
            end
        end
    end
end

if min_dist < RADIUS then
    error("points on top of each other, run me again")
end

io.write('<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n',
         '<svg svg="http://www.w3.org/2000/svg" version="1.0"',
         ' width="', WD, '" height="', HT, '">\n')
for i, p in ipairs(P) do
    local color = COLOR.normal
    if i == closest_a or i == closest_b then color = COLOR.closest end
    io.write(' <circle cx="', RADIUS + p.x, '" cy="', RADIUS + p.y,
             '" r="', RADIUS, '" style="fill:', color, '"/>\n')
end
io.write('</svg>\n')

설명

이 파일이 나타내는 바에 대한 한 줄 설명을 추가합니다

이 파일에 묘사된 항목

다음을 묘사함

image/svg+xml

120742ed70c3028e512f55d9b9e19453b4a7df2f

1,365 바이트

256 화소

256 화소

파일 역사

날짜/시간 링크를 클릭하면 해당 시간의 파일을 볼 수 있습니다.

날짜/시간섬네일크기사용자설명
현재2009년 6월 22일 (월) 13:032009년 6월 22일 (월) 13:03 판의 섬네일256 × 256 (1 KB)Qef{{Information |Description={{en|1=Closest pair of points shown in red.}} |Source=Own work by uploader |Author=Qef |Date=2009-06-22 |Permission= |other_versions=Bitmap version: file:ClosestPair.png }} <!--{{ImageUpload|full}}--> [[Catego

다음 문서 1개가 이 파일을 사용하고 있습니다:

이 파일을 사용하고 있는 모든 위키의 문서 목록

다음 위키에서 이 파일을 사용하고 있습니다: