Ok. I'm not experienced at all, and I need to program a set of different math formulas into a code.
Here is the first step I'm trying to take. I have an octahedron that has 8 plates. Each plate is composed of 3 vectors. There are 6 vectors in total and they are denoted as 1,2,3,4,5,6. Vectors are 1={1,0,0}, 2={0,1,0}, 3={-1,0,0}, 4={0,-1,0}, 5={0,0,1}, 6={0,0,-1} }.
These are the plates and each is composed out of the 3 vectors listed.
Plate 1= vector 1, vector 2, vector 5
Plate 2=2,3,5
Plate 3=3,4,5
Plate 4= 4,1,5
Plate 5=1,2,6
Plate 6=2,3,6
Plate 7= 3,4,6
Plate 8= 4,1, 6
So this is what I'm trying to do. I want to sum up all the vectors that compose each plate and divide by 3 to find the centroid. So the answer will look some like this: (x/3, y/3, z/3).
then I want the program to list each plate and the vectors it is associated with, and then give me the centroid.
Please help me in anyway you can. I know this a vague question, but I have no where else to turn and this has been stumping for the past week.
Here is my code so far:
#include <iostream>
using namespace std;
int main()
{
float Vector[6][3] = {{1,0,0}, {0,1,0}, {-1,0,0}, {0,-1,0}, {0,0,1}, {0,0,-1} };
int Plate[8][3] = {{1,2,5}, {2,3,5}, {3,4,5}, {4,1,5}, {1,2,6}, {2,3,6}, {3,4,6}, {4,1,6} };
float R[8][3];
for (int i=0; i<8; i++)
{
int k = Plate[i][1];
int l = Plate[i][2];
int m = Plate[i][3];
for (int j=0; j<3; j++)
{
R[i][j]=(Vector[k][j]+Vector[l][j]+Vector[m][j])/3;
}
cout << "Centroid[" << i+1 << "]: ";
cout << R[i][1] << R[i][2] << R[i][3] << endl << endl;
return 0;
}