• 11-30-2005
dlf
Hello everyone,

I am very new to c++ and only know the basics.

I am having problems with the code below. I want the user to be able to specify 3 coordinates which can then be added to 3 other coordinates (already specified earlier on in the program) to allow a line to be translated.

(I hope that makes sense)

Just wondering if anyone could give me some advice or tips?

dlf.

Code:

```void translate_line(double line[][3]) {   double translation [2][3];     printf("\nHow much would you like to translate the line by?\n(Between -1000 and 1000):");   scanf("%lf, %lf, %lf", &translation[0][0], &translation[0][1], &translation[0][2]);     double translate_line=[line]+[translation]   //double translateda=((line[0][0])+(translation[][0]),(line[0][1])+(translation[][1]),(line[0][2])+(translation[][2]));   //double translatedb=((line[1][0])+(translation[][0]),(line[1][1])+(translation[][1]),(line[1][2])+(translation[][2]));     printf("\nThe new start coordinates are: (%lf,%lf,%lf)", translate_line);   //printf("\nThe new end coordinates are: (%lf,%lf,%lf)", translatedb); }```
• 11-30-2005
7stud
Presumably, the coordinates entered earlier are contained in the array:

double line[][3]

So, you have to get the coordinates from that array. If the coordinates you are interested in translating are in row 0 of that array, then you would access them like this:

line[0][0], line[0][1], line[0][2]
• 11-30-2005
dlf
If I had 2 arrays for 2 points and each point had a x, y and z coordinate.

How would I add a translation for point 1 in one line and point 2 in another line?

So 2 lines of code to add 3 original coordinates to 3 translated coordinates.
• 11-30-2005
7stud
Quote:

If I had 2 arrays for 2 points and each point had a x, y and z coordinate.
Your arrays contain values of type double. I showed you how to retrieve a specific value at a specific location in an array. So, your question boils down to: how do I add two doubles together? You get one double from one array, and you get another double from the other array, and you add them together. Where you put the sum is up to you.