Skip to content

Instantly share code, notes, and snippets.

@Kreijstal
Last active February 24, 2018 16:21
Show Gist options
  • Save Kreijstal/9f73f21df5f5669cf95e895c1a2da4c9 to your computer and use it in GitHub Desktop.
Save Kreijstal/9f73f21df5f5669cf95e895c1a2da4c9 to your computer and use it in GitHub Desktop.
Mathematica and fun!
(*So sometimes I just want to show something very fast and I want for mathematica to do it for me, so after tryng very hard I came up with this*)
(*Previews and evalueates an expression*)
preview[x_] :=
TraditionalForm[
Row[{TraditionalForm[HoldForm[x]], "=",
x}]]; SetAttributes[preview, HoldFirst]
a = {6, 3, 0};
b = {9, 6, 0};
c = {9, 3, 3};
d = {6, 6, 3};
points = {{"a", a}, {"b", b}, {"c", c}, {"d", d}};
Print[preview[a]]; Print[preview[b]];
Print[preview[c]]; Print[preview[d]];
Print[Show[
Graphics3D[{Red, PointSize[0.06], Point[Map[#[[2]] &, points]]}],
Graphics3D[{Gray,
Text[Style[#[[1]], Bold, FontSize -> 18], 1 #[[2]]] & /@ points}],
Graphics3D@Line[{{a, b}, {b, c}, {c, d}, {d, a}, {d, b}, {a, c}}],
Boxed -> False]]
Print["Versuch der schewerpunkt ABC zu finden"]
Print[Row[{preview[e = (a + b)/2],
" Das ist Mittelpunkt von AB, Ich nenne es punkt e"}]];
points = {{"a", a}, {"b", b}, {"c", c}, {"d", d}, {"e", e}}; Print[
Show[Graphics3D[{Red, PointSize[0.06],
Point[Map[#[[2]] &, points]]}],
Graphics3D[{Gray,
Text[Style[#[[1]], Bold, FontSize -> 18], 1 #[[2]]] & /@ points}],
Graphics3D@Line[{{a, b}, {b, c}, {c, d}, {d, a}, {d, b}, {a, c}}],
Boxed -> False]]
Print[Row[{preview[e + \[Lambda] (c - e)], " Das ist Gerade EC"}]]
Print[Show[
Graphics3D[{Red, PointSize[0.06], Point[Map[#[[2]] &, points]]}],
Graphics3D[{Gray,
Text[Style[#[[1]], Bold, FontSize -> 18], 1 #[[2]]] & /@ points}],
Graphics3D@
Line[{{a, b}, {b, c}, {c, d}, {d, a}, {d, b}, {a, c}, {e, c}}],
Boxed -> False]]
Print[Row[{preview[S1 = (c - e)*1/3 + e],
" Das ist der schwerpunkt von ABC, weil \[Lambda]=1/3 von EC der \
Schwerpunkt sein musst, ich nenne es S1"}]]
points = {{"a", a}, {"b", b}, {"c", c}, {"d", d}, {"e", e}, {"S1",
S1}};
Print[Show[
Graphics3D[{Red, PointSize[0.06], Point[Map[#[[2]] &, points]]}],
Graphics3D[{Gray,
Text[Style[#[[1]], Bold, FontSize -> 18], 1 #[[2]]] & /@ points}],
Graphics3D@
Line[{{a, b}, {b, c}, {c, d}, {d, a}, {d, b}, {a, c}, {e, c}}],
Boxed -> False]]
Print["Versuch der schewerpunkt BCD zu finden"]
Print[Row[{preview[f = (b + c)/2],
" Das ist Mittelpunkt von BC, Ich nenne es punkt f"}]];
Print[Row[{preview[f + \[Lambda] (d - f)], " Das ist Gerade FD"}]]
Print[Row[{preview[S2 = (d - f)*1/3 + f],
" Das ist der schwerpunkt von BCD, weil \[Lambda]=1/3 von FD der \
Schwerpunkt sein musst, ich nenne es S2"}]]
points = {{"a", a}, {"b", b}, {"c", c}, {"d", d}, {"S1", S1}, {"S2",
S2}, {"e", e}, {"f", f}};
Print[Show[
Graphics3D[{Red, PointSize[0.06], Point[Map[#[[2]] &, points]]}],
Graphics3D[{Gray,
Text[Style[#[[1]], Bold, FontSize -> 18], 1 #[[2]]] & /@ points}],
Graphics3D@
Line[{{a, b}, {b, c}, {c, d}, {d, a}, {d, b}, {a, c}, {e, c}, {f,
d}}], Boxed -> False]]
Print[Row[{TraditionalForm[
HoldForm[S1 + \[Lambda] (d - S1) == S2 + \[Lambda] (a - S2)]],
"Der Schnittpunkt zwischen S1d und S2a ist der Schwerpunkt des \
Tetraeder"}]]
Print["Schwerpunkt ist {7.5,4.5,1.5} weil \[Lambda]=0.25, ich nenne \
es p"]
p = {7.5, 4.5, 1.5}
points = {{"a", a}, {"b", b}, {"c", c}, {"d", d}, {"S1", S1}, {"S2",
S2}, {"p", p}};
Print[Show[
Graphics3D[{Red, PointSize[0.06], Point[Map[#[[2]] &, points]]}],
Graphics3D[{Gray,
Text[Style[#[[1]], Bold, FontSize -> 18], 1 #[[2]]] & /@ points}],
Graphics3D@
Line[{{a, b}, {b, c}, {c, d}, {d, a}, {d, b}, {a, c}, {S1, d}, {S2,
a}}], Boxed -> False]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment