I've been trying to plot spheres and points, given the (c_x, c_y, c_z) centre coordinates of the sphere and (x, y, z) coordinates of the points, like this:
Show[Graphics3D[
{
{PointSize[Medium], Point[{{-261.6645, 2.3550077, -2.069712}}]},
{PointSize[Medium], Point[{{-263.8915, 0.4822703, -2.371802}}]},
{Opacity[0.5], Red, Sphere[{-260.072, 3.06565, -1.28551}, 3.4/2]},
{Opacity[0.5], Sphere[{-262.5363, 0.7417043, -2.528322}, 3.4/2]}
}
],
Axes -> True]
My goal now is to do the same but for more points and spheres and in a more automatic way: I have a file (points.txt) that has the (x,y,z) values of all points I want to plot, each coordinate has its column, and another file (sphere.txt) which has the coordinates of the centre of every sphere I also want to plot (again each coordinate is in a separate column)
Is there an easy way to indicate that Graphics3D (or another function?) must plot every point from points.txt and sphere in sphere.txt?
Points.txt:
ID X Y Z
0 -457.7842 0 0
1 -394.908 0 0
2 -345.2658 0 0
3 -326.8692 0 0
4 -256.3814 0 0
5 -203.4865 0 0
6 -132.9539 0 0
7 -63.00377 0 0
8 185.97179 0 0
9 209.24666 0 0
10 438.78941 0 0
11 -62.70032 0.8898561 1.9836796
12 -57.64477 2.9849146 3.2990784
13 -256.9517 0.3147554 0.310139
Spheres.txt
SphereID X Y Z
0 -263.7371 0.2212362 -1.553052
1 -393.6699 0.3578 -2.478324
2 -263.3724 -7.979184 -0.449041
3 -261.0845 3.0958525 1.9232374
4 -256.401 -1.259318 -0.081782
5 186.51078 1.0394365 -0.505206
points = Import["points.txt", "Data"][[2 ;; -1]][[;; , 2 ;; -1]]; spheres = Import["sphere.txt", "Data"][[2 ;; -1]][[;; , 2 ;; -1]]; Graphics3D[{{PointSize[Medium], Point@points}, {Opacity[0.5], Red, Sphere[#, 3.4/2]} & /@ spheres}, Axes -> True]
$\endgroup$Part
function in document (use F1 key )can find such usage. For example,{x,a,b,c}[[2;;-1]]
get{a,b,c}
. $\endgroup$