0
$\begingroup$

I'm new to mathematica software, this going to be difficult to explain but, I have an assignment to make a random numbers generator for upper-limb joints range of movement [ROM].

I divided the joints into 2 groups, shoulder group with 3 ROM, and the second group is Elbow-forearm, witch has 2 ROM. both groups have a limit range of movement [ROM] and I divided it to 4 ranges for comparison.

I think the table on the attached photo at the end will make it easy to understand what I'm trying to explain.

so, I wrote the code @mathematica and its fine, but in the result I tried many times to change the points color but I couldn't. I would like to change the color of the points so I can compare it easily later. also if you have any other ideas for showing the result in a different and nice graphics, please tell me.

thanks in advance.

note: I posted 1 code for 1 group and 1 range. the [ixx,iyy,izz] in the code is [θ1,θ2,θ3] for group 1.

a2 = 1.41421356; a3 = 1.7320508; pi = 3.141592;
ixx = 45; 
iyy = 45; 
izz = 15;
iran = ixx*iyy*izz; 
ixy = ixx*iyy;
r1 = a2*iran; 
r2 = a3*iran; 
r3 = pi*iran; 
print[iran]; 
rnd[1] = 1.23456;
rnd[2] = 5.43210;
rnd[3] = 2.71828;
Do[ir1[i] = i;
 rndi = r1*rnd[1] + r2*rnd[2] + r3*rnd[3]; 
 irnd = IntegerPart[rndi];
 irn0 = IntegerPart[rndi/iran];
 ri00 = irn0*iran; 
 ir00 = IntegerPart[ri00];
 ir10[i] = irnd - ir00; 
 rnd[1] = rnd[2];
 rnd[2] = rnd[3];
 rnd[3] = rndi - ri00,{i, 1, iran}];
Do[ir = ir10[j];
 j1 = ir1[j];
 i1 = ir1[ir];
 ir1[j] = i1;
 ir1[ir] = j1, {j, 1, iran}]; 
Do[iri = ir1[k];
 iz0 = IntegerPart[iri/ixy];
 iz[k] = iz0 + 1;
 iy0 = IntegerPart[(iri - iz0*ixy)/ixx];
 iy[k] = iy0 + 1;
 ix[k] = iri - iz0*ixy - iy0*ixx + 1, {k, 1, iran}]; 
Do[,{i, 1, iran}];
xyz1 = Table[Point[{ix[i], iy[i], iz[i]}], {i, 1, iran}]
Show[Graphics3D[xyz1], Axes -> True]

enter image description here

$\endgroup$

closed as unclear what you're asking by m_goldberg, Feyre, Sascha, corey979, gpap Jan 30 '17 at 15:44

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ thank you for replying, I did mention in the notes how to make it run fast witch will take only 3-5 sec for the result. I thought it would be necessary to show the whole code. apology for that. the main problem its at the end of the code; Do[i, 1, iran]; xyz1 = Table[Point[{ix[i], iy[i], iz[i]}], {i, 1, iran}] Show[Graphics3D[xyz1], Axes -> True] $\endgroup$ – Hwajees Jan 30 '17 at 7:02
  • $\begingroup$ I have change it and deleted the "Print" in the code now its will take 2-5 sec to run. thanks again for the comment. $\endgroup$ – Hwajees Jan 30 '17 at 7:07
2
$\begingroup$

As to how to change the color, you may write the very last code line a bit changed:

Show[Graphics3D[{Red, xyz1}], Axes -> True]

with the effect:

enter image description here

or even this way indicating by colors layers of points with different height :

lst = Table[{ix[i], iy[i], iz[i]}, {i, 1, iran}];
Manipulate[
 ListPointPlot3D[lst, ColorFunction -> Function[{x, y, z}, Hue[z/n]]], {n, Range[15]}]

and try to play with n. For n=6 it looks as follows:

enter image description here

Besides you fave a few unnecessary lines containing syntactic errors. These are (1) print[iran]; and (2) Do[,{i, 1, iran}];. You can remove them without any loss.

Evidently, this code is written in a procedural way, while in Mma it could be rewritten in a much more concise fashion, but here it is difficult to help you without knowing your ideas of what is done during the calculations. In a moment it is not vitally necessary, however, since the code works fast enough.

Have fun!

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.