How can I stop the label from moving up and down, when rotating using the mouse?
Manipulate[
v = {vx, vy, vz};
start = {sx, sy, sz};
Show[
Graphics3D[{Black,
Table[{Dashing[0.005], Line[{{i, -5, 0}, {i, 5, 0}}],
Line[{{-5, i, 0}, {5, i, 0}}],
Line[{{-.2, 0, i}, {.2, 0, i}}]}, {i, -5, 5}], Thick,
Arrow[{{0, 0, -5}, {0, 0, 5.5}}],
Style[Arrow[{{0, -5, 0}, {0, 5.5, 0}}], Antialiasing -> True],
Arrow[{{-5, 0, 0}, {5.5, 0, 0}}],
Text[Style["x", 16, Italic], {5.8, 0, 0}],
Text[Style["y", 16, Italic], {0, 5.8, 0}],
Text[Style["z", 16, Italic], {0, 0, 5.8}],
Red,
Arrow[Tube[{start, start + v}]],
Purple,
If[stedvektor,
Arrow[{o, v}]],
If[koord && stedvektor, {
PointSize -> 0.008, Point[{vx, vy, 0}], Dashing[{.005, .005}],
Line[{{vx, vy, 0}, v, {0, 0, vz}}],
Line[{{0, vy, 0}, {vx, vy, 0}, {vx, 0, 0}}],
(*Text[Style[vx,16],{vx,0,.5}],Text[Style[vy,16],{0,vy,.5}],
Text[Style[vz,16],{.5,.5,vz}],*)
Text[Style[Row[{"(", nf[vx], ", ", nf[vy], ", ", nf[vz], " )"}],
12], {vx + 1, vy + 1, vz + .3}]}]
}], PlotRange -> {{-5.5, 5.5}, {-5.5, 5.5}, {-5.5, 5.5}},
AxesLabel -> {Style["x", Italic], Style["y", Italic],
Style["z", Italic]}, Boxed -> False, ImageSize -> {290, 300},
Axes -> False, Boxed -> False,
PlotLabel -> If[koord, Text[Style[Row[{vec["a"], " = ", ( {
{nf[vx]},
{nf[vy]},
{nf[vz]}
} )}], Red, 14]],
Text[Style[Row[{vec["a"], " = ", ( {
{Subscript[a, 1]},
{Subscript[a, 2]},
{Subscript[a, 3]}
} )}], Red, 14]]
],
ViewPoint ->
1200 {Cos[-p[[1]]] Sin[p[[2]]], Sin[-p[[1]]] Sin[p[[2]]],
Cos[p[[2]]]},
ViewAngle -> 0.0009,
SphericalRegion -> True],
Row[{
Control[{{dimension, 2, "Antal dimensioner"}, {1, 2, 3}}],
Control[{{koord, True, "Vis koordinater"}, {True, False}}],
Control[{{stedvektor, False, "Vis stedvektor"}, {True, False}}]},
Spacer[20]],
Style[Row[{"Vektor ", vec[a]}], 12, Bold],
{{vx, 3, Subscript[a, 1]}, -5, 5, ControlType -> Slider,
ImageSize -> Tiny, ControlPlacement -> Left},
{{vy, 1, Subscript[a, 2]}, -5, 5, ControlType -> Slider,
ImageSize -> Tiny, ControlPlacement -> Left},
{{vz, 3, Subscript[a, 3]}, -5, 5, ControlType -> Slider,
ImageSize -> Tiny, ControlPlacement -> Left},
Delimiter,
Style["Startpunkt", 12, Bold],
{{sx, 2, Subscript[x, 0]}, -5, 5, ControlType -> Slider,
ImageSize -> Tiny, ControlPlacement -> Left},
{{sy, -2, Subscript[y, 0]}, -5, 5, ControlType -> Slider,
ImageSize -> Tiny, ControlPlacement -> Left},
{{sz, 1, Subscript[z, 0]}, -5, 5, ControlType -> Slider,
ImageSize -> Tiny, ControlPlacement -> Left},
{{start, {2, -2, 1}}, ControlType -> None},
{{o, {0, 0, 0}}, ControlType -> None},
Initialization :> (
p := {2 Pi - Pi/4, Pi/3};
vec[a_] := Style[OverVector[a], Bold];
nf[n_] := NumberForm[n, {2, 1}];
halfway[v_] :=
0.5 Norm[v] {Cos[(ArcTan @@ v - 1.5 ArcTan[Norm[v], .4])],
Sin[(ArcTan @@ v - 1.5 ArcTan[Norm[v], .4])]};
halfway2[v_] :=
0.5 Norm[v] {Cos[(ArcTan @@ v - 2.5 ArcTan[Norm[v], .4])],
Sin[(ArcTan @@ v - 2.5 ArcTan[Norm[v], .4])]}),
TrackedSymbols :> {start, slut, koord, stedvektor, dimension, vx, vy,
vz, sx, sy, sz, p}
]
{}
as the third argument ofIf
to eliminate the pink error notice, e.g.If[stedvektor, Arrow[{o, v}], {}]
. That doesn't fix the jumping label however. $\endgroup$