File:Catenary properties.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(SVG file, nominally 520 × 396 pixels, file size: 3 KB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary[edit]

Description diagram of a catenary showing some properties
Source Own work
Author Vernanimalcula
SVG development
InfoField
 
The SVG code is valid.
 
This vector image was created with a text editor.

Licensing[edit]

I, the copyright holder of this work, hereby publish it under the following licenses:
GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike Attribution-Share Alike 4.0 International, 3.0 Unported, 2.5 Generic, 2.0 Generic and 1.0 Generic license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
You may select the license of your choice.

Source program[edit]

The image is the output of this Python program:

from math import cosh, sinh

# Catenary
w = 400.0
a = 100.0
b = a*cosh((w/2)/a)
l = a*sinh((w/2)/a)
h = b-a

W, H = w+120, h+120 # total size of SVG image
ox, oy = 40.0, 40.0 # offset of diagram in SVG image (in SVG coords)

def x2svg( x ):
   """ Converts mathematial x to SVG coordinate """
   return ox + w/2 + x

def y2svg( y ):
   """ Converts mathematial y to SVG coordinate """
   return oy - y

def tosvg( t ):
   """ Converts t=(x,y,x,y,...) (mathematical) to SVG coordinates """
   coords = ()
   for i in range(0,len(t),2):
      coords = coords + (x2svg(t[i]),y2svg(t[i+1]))
   return coords

def print_polyline( t ):
   """ SVG polyline given by mathematical coordinates """
   ilist = ' '.join( ['%i'] * len(t) )
   s = '<polyline points="%s" style="stroke:#00A;stroke-width:3;fill:none;"/>' % ilist
   print s % tosvg(t)

fontsize=36
def print_text( x, y, txt, color='#00A' ):
   """ Print text centered at mathematical coordinates """
   svgx = x2svg(x) - 0.25*len(txt)*fontsize
   svgy = y2svg(y) + 0.25*fontsize
   print '<text x="%i" y="%i" style="font-family:sans-serif;font-size:%i;font-style:italic;color:%s">%s</text>' % (svgx,svgy,fontsize,color,txt)

def print_arrow( x0, y0, x1, y1, x2, y2, x3, y3 ):
   """ Print arrow with lines given by mathematical coordinates """
   print_polyline((x0,y0,x1,y1))
   print_polyline((x2,y2,x0,y0,x3,y3))

def print_xarrow( x0, y0, l, d ):
   """ Print horicontal arrow; l = long line; d = short line """
   print_arrow( x0, y0, x0+l, y0, x0+d, y0+d, x0+d, y0-d )

def print_yarrow( x0, y0, l, d ):
   """ Print vertical arrow; l = long line; d = short line """
   print_arrow( x0, y0, x0, y0+l, x0+d, y0+d, x0-d, y0+d )

########################################################################

print """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
     width="%i"
     height="%i"
     viewBox="%i %i %i %i">""" % (W,H,0,0,W,H)

# Background
print '<rect id="background" x="0" y="0" width="%i" height="%i" style="fill:#FFF"/>' % (W,H)
print '<rect id="curve" x="%i" y="%i" width="%i" height="%i" style="fill:#DDF"/>' % (ox,oy,w,h)

# Circle of radius a
print '<circle cx="%i" cy="%i" r="%i" style="stroke:#00A;stroke-width:3;fill:none;"/>' % (x2svg(0),y2svg(a-h),a)
print_polyline(( 0, a-h, a, a-h))
print_text( 0.5*a, 1.14*a-h, 'a' )

# Catenary
n = 100
xvals = [ w*(float(i)/n) for i in range(-n/2,n/2+1) ]
p = ' '.join([ '%i %i' % tosvg((x,a*cosh(x/a)-b)) for x in xvals ])
s = 'stroke:#000; stroke-width:5; fill:none'
print '<polyline points="%s" style="%s"/>' % (p,s)
print_text( -0.4*w, -0.1*h, 'l', color='#000' )

# Arrows
y0, l, d = 20, 0.44*w, 0.025*w
print_text( 0, y0, 'w' )
print_xarrow( -w/2, y0,  l,  d )
print_xarrow(  w/2, y0, -l, -d )
x0, l = -0.55*w, 0.42*h
print_text( x0, -h/2, 'h' )
print_yarrow(  x0,  0, -l, -d )
print_yarrow(  x0, -h,  l,  d )

# Labels
print_text( 0, -1.25*h, 'b=h+a' )
fontsize=18
y = -1.1*h
print_text( -w/2, y, 'x=-w/2' )
print_text(    0, y, 'x=0' )
print_text(  w/2, y, 'x=w/2' )
x = 0.6 * w
print_text( x, 0,  'y=0' )
print_text( x, -h, 'y=-h' )

print "</svg>"

File history

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

Date/TimeThumbnailDimensionsUserComment
current21:04, 19 January 2008Thumbnail for version as of 21:04, 19 January 2008520 × 396 (3 KB)Vernanimalcula (talk | contribs){{Information |Description=diagram of a catenary showing some properties |Source=self-made |Date= |Author= Vernanimalcula |Permission= |other_versions= }}

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file: