Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'join point following some rules' topicStudent Support Forum > General > "join point following some rules"

Help | Reply To Topic
Author Comment/Response
francois
06/26/09 09:57am

Hi,

I have a list of points (i.e. {{x1,x2,x3},{...},...,{...}}) and I want them to be joined, but only if the distance between them is no more than a certain parameter.

I let you my code:

a1 = {1/2, Sqrt[3]/2, 0};
a2 = {-1/2, Sqrt[3]/2, 0};
a3 = {0, 1/Sqrt[3], Sqrt[2/3]};
a = {};
b = {};
c = {};
d = {};
n = 2;
For[i = -n, i < n, i++,
For[j = -n, j < n, j++,
For[k = -n, k < n, k++, a = Join[a, {2 i a1 + 2 j a2 + 2 k a3}]]]];
For[i = -n, i < n, i++,
For[j = -n, j < n, j++,
For[k = -n, k < n, k++,
b = Join[b, {(2 i + 1) a1 + 2 j a2 + 2 k a3}]]]];
For[i = -n, i < n, i++,
For[j = -n, j < n, j++,
For[k = -n, k < n, k++,
c = Join[c, {2 i a1 + (2 j + 1) a2 + 2 k a3}]]]];
For[i = -n, i < n, i++,
For[j = -n, j < n, j++,
For[k = -n, k < n, k++,
d = Join[d, {2 i a1 + 2 j a2 + (2 k + 1) a3}]]]];
e = Join[a, b, c, d];
z = {};
For[i = 1, i <= Length[e], i++,
For[j = 1, j <= Length[e], j++,
If[Norm[e[[i]] - e[[j]]] == 1, z = Join[z, {{i, j}}], z = z]]];
Show[Graphics3D[
For[i = 1, i <= Length[z], i++,
Line[{e[[z[[i, 1]]]], e[[z[[i, 2]]]]}]]]]


Sorry if my english isn't very good, I'm French.
Thank you.


Pour les francophones :

Je cherche a relier uniquement certains points d'une liste de coordonnées (ceux se trouvant à une certaines distance de certains autres), le code ci dessus ne donne pas de résultat valable et je n'ai pas trouvé de fonction "Joined" permetant de mettre une condition au niveau de la distance entre les points.




URL: ,
Help | Reply To Topic