Difference between revisions of "C++:3D Exercises"

From Progzoo
Jump to: navigation, search
(Created page with "Show the point of intersection where the plane A, B, C meets the line DE. The normal is shown. The end points D and E are shown. Also the point of intersection is also marked wi...")
 
Line 20: Line 20:
 
   float *r = new float[3];
 
   float *r = new float[3];
 
   for (int i=0;i<3;i++)
 
   for (int i=0;i<3;i++)
  r[i] = a[i]-b[i];
+
    r[i] = a[i]-b[i];
 
   return r;
 
   return r;
 
}
 
}
  
 
float *crossproduct(float a[3], float b[3]){
 
float *crossproduct(float a[3], float b[3]){
   GLfloat *r = new float[3];
+
   float *r = new float[3];
 
   r[0] = a[1]*b[2]-a[2]*b[1];
 
   r[0] = a[1]*b[2]-a[2]*b[1];
 
   r[1] = a[2]*b[0]-a[0]*b[2];
 
   r[1] = a[2]*b[0]-a[0]*b[2];
Line 34: Line 34:
 
int main(int argc, char **argv)
 
int main(int argc, char **argv)
 
{
 
{
   float A = new float[3];
+
   float *A = new float[3];
   A[0]=1; A[1]=0;A[2]=1;
+
   A={1,0,1};
  cout << A << endl;
+
  cout << A[0]<<" "<<A[1]<<" "<<A[2]<< endl;
 
   return 0;
 
   return 0;
 
}
 
}
 
]]></prog>
 
]]></prog>
 
</question>
 
</question>

Revision as of 08:16, 23 November 2011

Show the point of intersection where the plane A, B, C meets the line DE. The normal is shown.

The end points D and E are shown. Also the point of intersection is also marked with a sphere.

GLfloat A[3] = {1, 0, 0};
GLfloat B[3] = {-1, 2, 0};
GLfloat C[3] = {0, 1, 3};
GLfloat D[3] = {-1,-1,-1};
GLfloat E[3] = {1,2,3};

The normal to the plane has also been shown.


[Font] [Default] [Show] [Resize] [History] [Profile]