Skip to content

Instantly share code, notes, and snippets.

/gyroscope.m
Created Jul 15, 2017

Embed
What would you like to do?
Code to reproduce models used in https://physics.stackexchange.com/a/345789/58382
ClearAll@gyroModel;
gyroModel[\[Phi]_] := Module[{gyroX, gyroWidth, gyroRadius,
rodX1, rodX2, rodZ,
baseRodZ0, baseRodWidth,
origin,
rodHeight, v1, rodVec, rodLength, rodDir,
rodVecPerp
},
origin = {0, 0, 0};
rodHeight = 3;
v1 = rodHeight {0, 0, 1};
rodLength = 3;
rodDir = {Cos[\[Phi]], Sin[\[Phi]], 0};
rodVec = rodLength*rodDir;
rodVecPerp = Normalize@Cross[v1, rodVec];
baseRodZ0 = -3; baseRodWidth = 0.1;
gyroX = Mean@{rodX1, rodX2};
gyroWidth = .1; gyroRadius = 1;
Graphics3D[{
(* gyro Cylinder *)
Cylinder[{
origin + v1 + (rodLength/2 - gyroWidth) rodDir,
origin + v1 + (rodLength/2 + gyroWidth) rodDir
}, gyroRadius],
Cylinder[{
origin + v1,
origin + v1 + rodVec
}, .08],
{Red, Sphere[origin + v1, 0.1]},
Cylinder[{
origin,
origin + v1
}, 0.08],
{LightGray,
Cylinder[{origin - 0.01 v1, origin + 0.01 v1}, 2]
},
{Arrowheads@0.05, Green,
Arrow@Tube[{origin + v1, origin + 1.4 v1}, .02],
Arrow@Tube[{
origin + v1 + rodVec/2 + {0, 0, -gyroRadius},
origin + v1 + rodVec/2 + {0, 0, -gyroRadius - 1}
}, .02]
},
(* rotating arrows *)
Red,
Table[
Arrow@Tube[{
#,
# +
gyroRadius (Sin[\[Theta]] Normalize@v1 -
Cos[\[Theta]] rodVecPerp)
} &[
origin + v1 + rodVec/2 +
gyroRadius (Cos[\[Theta]] Normalize@v1 +
Sin[\[Theta]] rodVecPerp)],
0.02
],
{\[Theta], 0, 2 Pi, 2 Pi/8}
],
(* purple arrows *)
Cyan,
Arrow@Tube[{#, # + rodDir} &[
origin + v1 + rodVec/2 + {0, 0, gyroRadius}
]
],
Arrow@Tube[{#, # - rodDir} &[
origin + v1 + rodVec/2 - {0, 0, gyroRadius}
]
],
(* new velocity arrows *)
Orange,
Arrow@Tube[{#, # + .5 rodDir - rodVecPerp} &[
origin + v1 + rodVec/2 + {0, 0, gyroRadius}
]
],
Arrow@Tube[{#, # - .5 rodDir + rodVecPerp} &[
origin + v1 + rodVec/2 - {0, 0, gyroRadius}
]
]
},
Boxed -> False,
RotationAction -> "Clip",
PlotRange -> {{-#, #}, {-#, #}, {0, 4.6}} &@3
]
]
gyroModel[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.