Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Cross-sections

By: a guest on Sep 28th, 2012  |  syntax: None  |  size: 0.69 KB  |  views: 30  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ptsph[\[Theta]_, \[Phi]_] := {Sin[\[Theta]] Sin[\[Phi]],
  2.   Cos[\[Theta]] Sin[\[Phi]], Cos[\[Phi]]}
  3. points = {ptsph[-0.2, \[Pi]/2 + 0.01], ptsph[0.2, \[Pi]/2 - 0.01],
  4.    ptsph[\[Pi] - 0.2, \[Pi]/2 + 0.01],
  5.    ptsph[\[Pi] + 0.2, \[Pi]/2 - 0.01]};
  6. slice[z_, {pt1_, pt2_}] :=
  7.  If[# == {}, Null, \[Lambda] pt1 + (1 - \[Lambda]) pt2 /. #[[1]]] &[
  8.   Quiet[Solve[\[Lambda] pt1[[3]] + (1 - \[Lambda]) pt2[[3]] == z &&
  9.      0 <= \[Lambda] <= 1, \[Lambda]]]]
  10. slice[z_] :=
  11.  Polygon[DeleteCases[slice[z, #] & /@ Subsets[points, {2}],
  12.     Null][[{1, 2, 4, 3}]]]
  13. Manipulate[
  14.  Graphics3D[{{Red, slice[z]}, {Opacity[0.5], Sphere[],
  15.     tetrahedron}}], {z, Cos[\[Pi]/2 + 0.01], Cos[\[Pi]/2 - 0.01]}]