File:Trisected perimeter point 3-4-5.svg

Description The trisected perimeter point of a 3-4-5 right triangle.
Date
Source Own work
Author David Eppstein
Permission
(Reusing this file)
Public domain I, the copyright holder of this work, release this work into the public domain. This applies worldwide.
In some countries this may not be legally possible; if so:
I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.
Category:Self-published work#Trisected%20perimeter%20point%203-4-5.svgCategory:PD-self#Trisected%20perimeter%20point%203-4-5.svg

Source code

This diagram was created as a pdf file by the following Python code, then recolored and labeled in Adobe Illustrator and converted to SVG.

from pyx import canvas,path,color

def meet(p,q):
    return [p[i-1]*q[i]-q[i-1]*p[i] for i in [2,0,1]]

def sign(p,r,q):
    L = meet(p,q)
    return sum(L[i]*r[i] for i in [0,1,2])

A = [0,3,1]
B = [0,0,1]
C = [4,0,1]

lo = 0
hi = 3
for i in range(40):
    x = (lo + hi) / 2.0
    AP = [4-x,0,1]
    BP = [4-0.8*(4-x),0.6*(4-x),1]
    CP = [0,x,1]
    if sign(meet(A,AP),meet(B,BP),meet(C,CP)) < 0:
        hi = x
    else:
        lo = x

c = canvas.canvas()

def line(p,q):
    c.stroke(path.line(p[0],p[1],q[0],q[1]),[color.rgb.black])

for p,q in [(A,B),(A,C),(B,C),(A,AP),(B,BP),(C,CP)]:
    line(p,q)

c.writePDFfile("Trisected perimeter point 3-4-5")
Category:Files by User:David Eppstein from en.wikipedia Category:Right triangles
Category:Files by User:David Eppstein from en.wikipedia Category:PD-self Category:Pages using deprecated source tags Category:Right triangles Category:Self-published work