{
"cells": [
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t = linspace(0,8*pi,200)\n",
"x = sin.(t)\n",
"y = cos.(t)\n",
"z = 20*t\n",
"\n",
"using Plots\n",
"\n",
"f(t) = m / norm(m)\n",
"T = mapslices(f(t))\n",
"dx = mapslices(gradient)\n",
"dxx = mapslices(gradient)\n",
"B = cross(dx, dxx)\n",
"plot(x,y,z)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = (2+cos.(1.5.*t)).*cos.(t)\n",
"y = (2+cos.(1.5.*t)).*sin.(t)\n",
"z = sin.(1.5.*t)\n",
"plot(x,y,z)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"a = 2;\n",
"b = 2;\n",
"T = 2*pi*sqrt(a^2+b^2);\n",
"kappa = abs(a)/(a^2+b^2);\n",
"nu = 1;\n",
"tau = b/(a^2+b^2);\n",
"kappa = (s)kappa;\n",
"nu = (s)nu;\n",
"tau = (s)tau;\n",
"A = (s)[ 0 kappa(s)*nu(s) 0\n",
" -kappa(s)*nu(s) 0 tau(s)*nu(s)\n",
" 0 -tau(s)*nu(s) 0]\n",
"f = (s,y)reshape(A(s)*reshape(y,[3 3]),9,1); % Handle matrix ODE\n",
"sspan = linspace(0,T,20);\n",
"y0 = eye(3); % [e1 e2 e3;n1 n2 n3;b1 b2 b3]\n",
"[s,y] = ode45(f,sspan,y0(:));\n",
"y = reshape(y.,[3 3 numel(y)/9])\n",
"\n",
"% Three basis vectors as functions of arc length\n",
"E = y(:,[1 4 7]).'; % [e11 ... e1m;e21 ... e2m;e31 ... e3m]\n",
"N = y(:,[2 5 8]).'; % [n11 ... n1m;n21 ... n2m;n31 ... n3m]\n",
"B = y(:,[3 6 9]).'; % [b11 ... b1m;b21 ... b2m;e31 ... b3m]\n",
"\n",
"% Circular helix\n",
"t = s.'/sqrt(a^2+b^2);\n",
"x = a*cos(t);\n",
"y = a*sin(t);\n",
"z = b*t;\n",
"\n",
"figure\n",
"plot3(x,y,z,'r')\n",
"hold on\n",
"axis equal\n",
"grid on"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 0.6.3",
"language": "julia",
"name": "julia-0.6"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "0.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}