파일:Ballistic-trajectories-planet2.svg

testwiki
둘러보기로 이동 검색으로 이동
    원본 파일 (SVG 파일, 실제 크기 720 × 440 픽셀, 파일 크기: 4 KB)

    이 파일은 위키미디어 공용에 있으며, 다른 프로젝트에서 사용하고 있을 가능성이 있습니다. 해당 파일에 대한 설명이 아래에 나와 있습니다.

    파일 설명

    설명
    English: Plot of two ballistic trajectories with identical initial velocity, one with a uniform gravity field (blue) and one in the central potential field of a planet (orange). The trajectories are one parabola and one ellipse, respectively. The graphical representation is accurately computed using the script, given below.
    날짜
    출처 자작
    저자 Geek3
    다른 버전 Ballistic-trajectories-planet.svg
    SVG 발전
    InfoField
     이 SVG 파일의 소스 코드 문법이 올바릅니다.
     이 벡터 그림은 Python(으)로 제작되었습니다.
    소스 코드
    InfoField

    Python code

    Python svgwrite code
    #!/usr/bin/python3
    # -*- coding: utf8 -*-
    
    try:
        import svgwrite
    except ImportError:
        print("requires svgwrite library: https://pypi.org/project/svgwrite/")
        # documentation at https://svgwrite.readthedocs.io/
        exit(1)
    
    from math import *
    
    # document
    size = 720, 440
    name = "Ballistic-trajectories-planet2"
    doc = svgwrite.Drawing(name + ".svg", profile="full", size=size)
    doc.set_desc(name, name + """.svg
    https://commons.wikimedia.org/wiki/File:""" + name + """.svg
    rights: Creative Commons Attribution-Share Alike 4.0 International license""")
    
    # background
    doc.add(doc.rect(id="background", insert=(0, 0), size=size, fill="white", stroke="none"))
    
    cx, cy = 72, 1720
    R = 1500
    lw = 5
    dash = "5,9"
    c1, c2 = "#0072bd", "#d95319"
    vx, vy = 0.4, 0.4 # in units of sqrt(R*g)
    
    # gradients
    rgrad = doc.defs.add(doc.radialGradient(id='rgrad', center=(0.5,0.5), r=0.5, gradientUnits='objectBoundingBox'))
    rgrad.add_stop_color(offset=0.93, color='#ffffff')
    rgrad.add_stop_color(offset=1, color='#ddc099')
    lgrad = doc.defs.add(doc.linearGradient(id='lgrad', start=(0,0), end=(0,1), gradientUnits='objectBoundingBox'))
    lgrad.add_stop_color(offset=0, color='#ddc099')
    lgrad.add_stop_color(offset=1, color='#ffffff')
    
    g = doc.add(doc.g(transform="translate({:.1f}, {:.1f})".format(cx, cy), fill="none"))
    g.add(doc.rect(insert=(-cx, -R), size=(size[0], 0.07*R), fill="url(#lgrad)", stroke="none"))
    g.add(doc.path(d="M {:.1f},{:.1f} h {:.1f}".format(-cx, -R, size[0]), stroke="black", stroke_width="3"))
    g.add(doc.circle(r=str(R), center=(0,0), fill="url(#rgrad)", stroke="black", stroke_width="3"))
    
    # trajectories
    def parabola(x1, x2, abc): # using a quadratic Bezier curve
        a, b, c = abc
        y1 = a + b * x1 + c * x1**2
        y2 = a + b * x2 + c * x2**2
        txt = "M {:.1f},{:.1f} Q {:.1f},{:.1f} {:.1f},{:.1f}"
        return txt.format(x1, y1, (x1+x2)/2, (y1+y2)/2 - c/2*(x2-x1)**2, x2, y2)
    
    def ellipse(p1, p2, abphi, l): # using arc
        a, b, phi = abphi
        c = 1
        if (pi/2-phi) % (2 * pi) > pi:
            c = 1 - c
        txt = "M {:.1f},{:.1f} A {:.1f},{:.1f} {:.1f} {:} {:} {:.1f},{:.1f}"
        return txt.format(p1[0], p1[1], a, b, degrees(phi), l, c, p2[0], p2[1])
    
    p0 = (0, -R)
    p1 = (2 * R * vx * vy, -R)
    abc = -R, -vy / vx, 0.5 / R / vx**2
    E2 = 2 - vx**2 - vy**2
    a = R / E2
    b = R * fabs(vx) / sqrt(E2)
    phi = asin(vx / sqrt(E2) * sqrt((2 * a * R - b**2 - R**2) / (a**2 - b**2))) - pi/2
    p2 = (-R * sin(2 * phi), R * cos(2 * phi))
    abphi = a, b, phi
    g.add(doc.path(d=ellipse(p2, p0, abphi, 1),
        stroke=c2, stroke_width=lw, stroke_dasharray=dash))
    g.add(doc.path(d=parabola(-cx, 0, abc) + " " + parabola(2*R*vx*vy, size[0]-cx, abc),
        stroke=c1, stroke_width=lw, stroke_dasharray=dash))
    g.add(doc.path(d=ellipse(p0, p2, abphi, 0), stroke=c2, stroke_width=lw))
    g.add(doc.path(d=parabola(p0[0], p1[0], abc), stroke=c1, stroke_width=lw))
    
    # arrows
    arrowd = "M {:.1f},{:.1f} V {:.1f} M {:.1f},{:.1f} L {:.1f},{:.1f} L {:.1f},{:.1f}".format(
        0, 0, 110, -13, 88, 0, 110, 13, 88)
    g.add(doc.path(transform="translate(0, {:.1f})".format(-R), d=arrowd,
        stroke="#777777", stroke_width="7", fill="none", stroke_linecap="butt"))
    g.add(doc.path(transform="translate({:.1f}, {:.1f})".format(*p1), d=arrowd,
        stroke="#777777", stroke_width="7", fill="none", stroke_linecap="butt"))
    g.add(doc.path(transform="rotate({:.2f}) translate(0, {:.1f})".format(degrees(2*phi-pi), -R), d=arrowd,
        stroke="#777777", stroke_width="7", fill="none", stroke_linecap="butt"))
    
    g.add(doc.circle(r="6", center=(0,0), fill="black", stroke="none"))
    g.add(doc.circle(r="6", center=p0, fill="black", stroke="none"))
    g.add(doc.circle(r="6", center=p1, fill="black", stroke="none"))
    g.add(doc.circle(r="6", center=p2, fill="black", stroke="none"))
    
    # text
    g.add(doc.text("g", font_size="30px", font_family="Bitstream Vera Sans",
        text_anchor="middle", transform="translate({:.1f}, {:.1f})".format(19, -0.955*R), stroke="none", fill="black"))
    g.add(doc.text("g", font_size="30px", font_family="Bitstream Vera Sans",
        text_anchor="middle", transform="translate({:.1f}, {:.1f})".format(19+p1[0], -0.955*R), stroke="none", fill="black"))
    g.add(doc.text("g'", font_size="30px", font_family="Bitstream Vera Sans",
        text_anchor="middle", transform="translate({:.1f}, {:.1f})".format(550, -1322), stroke="none", fill="black"))
    
    legend = doc.add(doc.g(transform="translate({:.1f}, {:.1f})".format(510, 20), fill="none"))
    legend.add(doc.rect(insert=(0, 0), size=(190, 100), fill="white", stroke="black", stroke_width="3"))
    legend.add(doc.path(d="M {:.1f},{:.1f} h {:.1f}".format(20, 30, 40), stroke=c1, stroke_width=lw))
    legend.add(doc.path(d="M {:.1f},{:.1f} h {:.1f}".format(20, 70, 40), stroke=c2, stroke_width=lw))
    legend.add(doc.text("flat", font_size="30px", font_family="Bitstream Vera Sans",
        text_anchor="start", transform="translate({:.1f}, {:.1f})".format(76, 39), stroke="none", fill="black"))
    legend.add(doc.text("planet", font_size="30px", font_family="Bitstream Vera Sans",
        text_anchor="start", transform="translate({:.1f}, {:.1f})".format(76, 79), stroke="none", fill="black"))
    
    doc.save(pretty=True)
    

    라이선스

    나는 아래 작품의 저작권자로서, 이 저작물을 다음과 같은 라이선스로 배포합니다:
    w:ko:크리에이티브 커먼즈
    저작자표시 동일조건변경허락
    이용자는 다음의 권리를 갖습니다:
    • 공유 및 이용 – 저작물의 복제, 배포, 전시, 공연 및 공중송신
    • 개작 – 저작물의 개작, 수정, 2차적저작물 창작
    다음과 같은 조건을 따라야 합니다:
    • 저작자표시 – 적절한 저작자 표시를 제공하고, 라이선스에 대한 링크를 제공하고, 변경사항이 있는지를 표시해야 합니다. 당신은 합리적인 방식으로 표시할 수 있지만, 어떤 방식으로든 사용권 허가자가 당신 또는 당신의 사용을 지지하는 방식으로 표시할 수 없습니다.
    • 동일조건변경허락 – 만약 당신이 이 저작물을 개작 또는 변형하거나 이 저작물을 기반으로 제작하는 경우, 당신은 당신의 기여물을 원저작물과 동일하거나 호환 가능한 라이선스에 따라 배포하여야 합니다.

    설명

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

    이 파일에 묘사된 항목

    다음을 묘사함

    image/svg+xml

    3e29a2a78e43f1ad0e0653baf1aa9420e8390190

    3,699 바이트

    440 화소

    720 화소

    파일 역사

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

    날짜/시간섬네일크기사용자설명
    현재2020년 10월 13일 (화) 14:032020년 10월 13일 (화) 14:03 판의 섬네일720 × 440 (4 KB)wikimediacommons>Geek3Uploaded own work with UploadWizard

    이 파일을 사용하는 문서가 없습니다.