{"id":897,"date":"2021-02-14T01:36:01","date_gmt":"2021-02-14T09:36:01","guid":{"rendered":"http:\/\/gantovnik.com\/bio-tips\/?p=897"},"modified":"2024-06-27T13:24:37","modified_gmt":"2024-06-27T20:24:37","slug":"161-euler-spiral-using-python","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2021\/02\/161-euler-spiral-using-python\/","title":{"rendered":"#161 Euler spiral using python"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/02\/example161.png?resize=600%2C400\" alt=\"\" width=\"600\" height=\"400\" class=\"alignnone size-full wp-image-898\" srcset=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/02\/example161.png?w=600&amp;ssl=1 600w, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/02\/example161.png?resize=300%2C200&amp;ssl=1 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>#161 Euler spiral using python<\/p>\n<p>The curve described by the parametric equations (x, y) = (S (t),C(t)) is called a clothoid (or Euler spiral) and has the property that its curvature<br \/>\nis proportional to the distance along the path of the curve.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nimport os\r\nfrom scipy.special import Fresnel\r\n\r\nos.chdir(r&#039;D:\\projects\\wordpress\\ex161&#039;) \r\nos.getcwd()\r\n\r\ndef main():\r\n    t = np.linspace(-10, 10, 1000)\r\n    plt.plot(*Fresnel(t), c=&#039;k&#039;)\r\n    plt.savefig(&quot;example161.png&quot;, dpi=100)\r\n    plt.show()\r\n\r\nif __name__ == &#039;__main__&#039;:\r\n    main()\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#161 Euler spiral using python The curve described by the parametric equations (x, y) = (S (t),C(t)) is called a clothoid (or Euler spiral) and has the property that its curvature is proportional to the distance along the path of the curve. import numpy as np import matplotlib.pyplot as plt import os from scipy.special import [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_lmt_disableupdate":"yes","_lmt_disable":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2],"tags":[120],"class_list":["post-897","post","type-post","status-publish","format-standard","hentry","category-python","tag-euler-spiral"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-et","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1242,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/210-parametric-curve-in-3d-2-2-2-2-2-2-2-2-2-2-2-2-2\/","url_meta":{"origin":897,"position":0},"title":"#223 Initial value problem in python","author":"gantovnik","date":"2021-11-29","format":false,"excerpt":"[code language=\"python\"] import numpy as np import matplotlib.pyplot as plt class IV_Problem: \"\"\" Initial value problem (IVP) class \"\"\" def __init__(self, rhs, y0, interval, name='IVP'): \"\"\" rhs 'right hand side' function of the ordinary differential equation f(t,y) y0 array with initial values interval start and end value of the interval\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex223.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1915,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/08\/373-scatterplot-with-multiple-semantics-using-seaborn-library\/","url_meta":{"origin":897,"position":1},"title":"#373 Scatterplot with multiple semantics using seaborn library","author":"gantovnik","date":"2023-08-09","format":false,"excerpt":"[code language=\"python\"] import numpy as np import matplotlib.pyplot as plt import os from scipy.special import fresnel #conda install -c anaconda seaborn import seaborn as sns sns.set_theme(style=\"whitegrid\") def main(): # Load the example diamonds dataset diamonds = sns.load_dataset(\"diamonds\") # Draw a scatter plot while assigning point colors and sizes to different\u2026","rel":"","context":"In &quot;plot&quot;","block_context":{"text":"plot","link":"https:\/\/gantovnik.com\/bio-tips\/category\/plot\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":1980,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/12\/397-spiral-that-goes-around-circular-paraboloid-by-python\/","url_meta":{"origin":897,"position":2},"title":"#397 Spiral that goes around circular paraboloid by python","author":"gantovnik","date":"2023-12-18","format":false,"excerpt":"[code language=\"python\"] import numpy as np import matplotlib.pyplot as plt fig = plt.figure() ax = plt.axes(projection='3d') # Surface ------------------ # Create the mesh in polar coordinates and compute corresponding Z r0 = 5 r = np.linspace(0, r0, 50) p = np.linspace(0, 2*np.pi, 50) R, P = np.meshgrid(r, p) Z =\u2026","rel":"","context":"In &quot;matplotlib&quot;","block_context":{"text":"matplotlib","link":"https:\/\/gantovnik.com\/bio-tips\/category\/matplotlib\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/12\/ex397.png?fit=640%2C480&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/12\/ex397.png?fit=640%2C480&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/12\/ex397.png?fit=640%2C480&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":2171,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/05\/424-an-animation-of-a-decaying-sine-curve-using-python\/","url_meta":{"origin":897,"position":3},"title":"#424 An animation of a decaying sine curve using python","author":"gantovnik","date":"2024-05-05","format":false,"excerpt":"[code language=\"python\"] import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation # Time step for the animation (s), max time to animate for (s). dt, tmax = 0.01, 5 # Signal frequency (s-1), decay constant (s-1). f, alpha = 2.5, 1 # These lists will hold the\u2026","rel":"","context":"In &quot;animation&quot;","block_context":{"text":"animation","link":"https:\/\/gantovnik.com\/bio-tips\/category\/animation\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/05\/ex424.gif?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/05\/ex424.gif?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/05\/ex424.gif?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3018,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/07\/441-parametric-curve-lemniscate-of-bernoulli-with-slider-in-python\/","url_meta":{"origin":897,"position":4},"title":"#441 Parametric curve Lemniscate of Bernoulli with Slider in python","author":"gantovnik","date":"2024-07-25","format":false,"excerpt":"import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import Slider def rx(t): return np.cos(t)\/(1+np.sin(t)**2) def ry(t): return np.sin(t)*np.cos(t)\/(1+np.sin(t)**2) t = 0 fig,ax1 = plt.subplots(1,1,figsize=(10,6)) plt.subplots_adjust(bottom=0.2) ax1.set_aspect('equal') ax1.set_ylim(-0.5,0.5) ax1.set_xlim(-1.2,1.2) ax1.title.set_text('Parametric curve: Lemniscate of Bernoulli') ax1.grid('on') r, = ax1.plot(rx(t), ry(t),'b', markersize=3) Pnt1, = ax1.plot(rx(t), ry(t),'ro', markersize=6) axt = plt.axes([0.25, 0.1,\u2026","rel":"","context":"In &quot;animation&quot;","block_context":{"text":"animation","link":"https:\/\/gantovnik.com\/bio-tips\/category\/animation\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/07\/ex441.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/07\/ex441.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/07\/ex441.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/07\/ex441.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":2053,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/01\/406-nonlinear-least-squares-fitting-using-leastsq-from-scipy-optimize-in-python\/","url_meta":{"origin":897,"position":5},"title":"#406 Nonlinear least squares fitting using leastsq from scipy.optimize in python","author":"gantovnik","date":"2024-01-14","format":false,"excerpt":"[code language=\"python\"] import numpy as np import matplotlib.pyplot as plt from scipy.optimize import leastsq A, freq, tau = 5, 4, 0.5 def f(t, A, freq, tau): return A * np.exp(-t\/tau) * np.cos(3*np.pi * freq * t) tmax, dt = 1, 0.01 t = np.arange(0, tmax, dt) yexact = f(t, A,\u2026","rel":"","context":"In &quot;matplotlib&quot;","block_context":{"text":"matplotlib","link":"https:\/\/gantovnik.com\/bio-tips\/category\/matplotlib\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex406.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex406.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex406.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/897","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/comments?post=897"}],"version-history":[{"count":2,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/897\/revisions"}],"predecessor-version":[{"id":2234,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/897\/revisions\/2234"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}