File:Alhazen hyperbola.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 400 × 400 pixels, file size: 3 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: A geometric solution to Alhazen's problem, seeking the point (red) at which two given points (blue) reflect to each other on a mirrored circle (black). The solution involves the inversions of the two given points through the circle (yellow) and the midpoint of the two inversion points (also yellow). A right hyperbola (red) passes through the two inversion points, centered at the midpoint of these two points, with its asymptotic lines (yellow, through midpoint) parallel and perpendicular to the bisector of the angle subtended by the given points at the circle center. The desired reflection point (red) is one of the crossing points of this hyperbola with the given circle.
    Date
    Source Own work
    Author David Eppstein
    SVG development
    InfoField
     The SVG code is valid.
     This vector image was created with an unknown SVG tool.

    Source code

    from PADS.SVG import *
    import sys
    from cmath import phase
    from math import pi
    
    scale=100
    bbox = (4+4j)*scale
    origin=(1.5+2.5j)*scale
    
    pointrad=4
    smallrad=3
    
    svg = SVG(bbox,sys.stdout)
    
    def place(p):
        return p*scale+origin
    
    a = -0.25-1.1j
    b = 2.2-1.1j
    
    ainv = 1/a.conjugate()
    binv = 1/b.conjugate()
    invmid = (ainv+binv)/2
    
    bisector = a/abs(a)+b/abs(b)
    bisector /= abs(bisector)
    
    def angle(p,q,r):
        """Clockwise turning angle"""
        pq = (p-q)/abs(p-q)
        qr = (q-r)/abs(q-r)
        return pi+phase(pq/qr)
    
    left = a/abs(a)
    right = b/abs(b)
    for i in range(20):
        reflex = (left+right)/abs(left+right)
        if angle(a,reflex,0) > angle(0,reflex,b):
            left = reflex
        else:
            right = reflex
    
    svg.circle(origin,scale,fill="none",stroke=colors.black) # unit circle
    svg.polyline([place(a),place(reflex),place(b)],fill="none",stroke=colors.blue)
    
    hyperx = [1.1,1.3,1.6,2,2.5,3.1,3.7,4.4,5.2,6.1,7.1,8.2,9.4,11,13]
    hyperx = [1/x for x in reversed(hyperx)]+hyperx
    unscaled = (ainv-invmid)/bisector
    hyperscale = (unscaled.real*unscaled.imag)**0.5*bisector
    hyperpos = [(x + 1j/x)*hyperscale+invmid for x in hyperx]
    hyperneg = [(-x - 1j/x)*hyperscale+invmid for x in hyperx]
    
    thin={"stroke-width":"0.5"}
    
    svg.group(fill="none",style=thin,stroke=colors.yellow)
    svg.segment(place(0),place(a*4))
    svg.segment(place(0),place(b*2))
    svg.segment(place(-4*bisector),place(4*bisector))
    svg.segment(place(-4j*bisector),place(4j*bisector))
    svg.segment(place(-4*bisector+invmid),place(4*bisector+invmid))
    svg.segment(place(-4j*bisector+invmid),place(4j*bisector+invmid))
    svg.ungroup()
    
    svg.group(fill="none",stroke=colors.red)
    svg.polycurve([place(q) for q in hyperpos])
    svg.polycurve([place(q) for q in hyperneg])
    svg.ungroup()
    
    svg.group(style=thin)
    
    svg.group(fill=colors.blue,stroke=colors.black)
    svg.circle(place(a),pointrad)
    svg.circle(place(b),pointrad)
    svg.ungroup()
    
    svg.group(fill=colors.yellow,stroke=colors.black)
    svg.circle(place(ainv),smallrad)
    svg.circle(place(binv),smallrad)
    svg.circle(place(invmid),smallrad)
    svg.ungroup()
    
    svg.circle(place(reflex),smallrad,fill=colors.red,stroke=colors.black)
    svg.ungroup()
    
    svg.close()
    

    Licensing

    David Eppstein, the copyright holder of this work, hereby publishes it under the following license:
    Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
    The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

    Captions

    Solution to Alhazen's problem on circular reflection, using a right hyperbola through the inversions of the given points, with asymptotic lines parallel to the bisector of the angle subtended by the points at the center of the mirrored circle.

    Items portrayed in this file

    depicts

    7 June 2025

    2,777 byte

    image/svg+xml

    a3152ba50ad472a0921517fce7fbe5b9a5220b29

    File history

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

    Date/TimeThumbnailDimensionsUserComment
    current07:19, 27 June 2025Thumbnail for version as of 07:19, 27 June 2025400 × 400 (3 KB)wikimediacommons>David EppsteinA little thicker

    There are no pages that use this file.