This is the code i have so far.
I'm just a tad stumped about how to translate the matrix I have.Code:#include <stdio.h>
#include <stdlib.h>
void enter_point(double point[3]);
void translate(double point[2][3]);
void scaling(double point[2][3]);
int main()
{
double line[2][3];
int menu_option;
for (menu_option=0;;menu_option++) //For loop with no end conditions, so it will keep repeating
{
printf("\n\n\tPlease choose from the menu\n\n");
printf(" *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n\n");
printf("\t*\t1.\t\tChange position of P1 (Where P=0)\t*\n");
printf("\t*\t2.\t\tChange position of P2 (Where P=1)\t*\n");
printf("\t*\t3.\t\tScale the line\t\t\t\t*\n");
printf("\t*\t4.\t\tRotate the line\t\t\t\t*\n");
printf("\t*\t5.\t\tTranslate the line\t\t\t*\n");
printf("\t*\t6.\t\tEvaluate a point on the line\t\t*\n");
printf("\t*\t7.\t\tExit the program\t\t\t*\n\n");
printf(" *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n\n\n");
printf("\tEnter your choice here\t\t");
scanf("\t%d", &menu_option);
if (menu_option==1) enter_point(line[0]);
else if (menu_option==2) enter_point(line[1]);
else if (menu_option==7) break; //Used to break the for loop and exit the program
else if (menu_option<1) printf("\n\n\tNo\n\tBetween 1 and 7\n\tYou retard\n");
else if (menu_option>7) printf("\n\n\tNo\n\tBetween 1 and 7\n\tYou retard\n");
}
}
void enter_point(double point[3])
{
printf("\n\nPlease enter the co-ordinates of your point\n");
printf("\nx co-ordinate=\t\t");
scanf("%lf", &point[0]);
printf("\ny co-ordinate=\t\t");
scanf("%lf", &point[1]);
printf("\nz co-ordinate=\t\t");
scanf("%lf", &point[2]);
}
void translate(double point[2][3])
{
double translation[1][3];
printf("Please enter the amounts you wish to translate the line by, for each axis");
printf("\nTranslation for x co-ordinate\t\t");
scanf("%lf", &translation[0]);
printf("\nTranslation for y co-ordinate\t\t");
scanf("%lf", &translation[1]);
printf("\nTranslation for z co-ordinate\t\t");
scanf("%lf", &translation[2]);
}
Does anyone know how I would ceate a new [1][3] matrix in the above function which I could add to my existing matrix.
Help much appreciated.
Cheers