Example #1
0
/*======== void add_point() ==========
Inputs:   struct matrix * points
         int x
         int y
         int z 
Returns: 
adds point (x, y, z) to points and increment points.lastcol
if points is full, should call grow on points
====================*/
void add_point( struct matrix * points, int x, int y, int z) {
  if(points->lastcol == points->cols){
    grow_matrix(points,points->cols*2);
  }
  points->m[0][points->lastcol] = (double)x;
  points->m[1][points->lastcol] = (double)y;
  points->m[2][points->lastcol] = (double)z;
  points->lastcol= points->lastcol+1;
}
Example #2
0
File: draw.c Project: stuydw/matrix
/*======== void add_point() ==========
Inputs:   struct matrix * points
         int x
         int y
         int z 
Returns: 
adds point (x, y, z) to points and increment points.lastcol
if points is full, should call grow on points
====================*/
void add_point( struct matrix * points, int x, int y, int z) {
  if(points->cols == points->lastcol)
    grow_matrix(points, points->cols + 1);
  int cols = points->lastcol;
  points->m[0][cols] = x;
  points->m[1][cols] = y;
  points->m[2][cols] = z;
  points->lastcol++;
}
Example #3
0
File: matrix.c Project: stuydw/3d
/*--------------void append_matrix()----------------
Inputs: struct matrix *a
        struct matrix *b
Returns:

adds all columns in a to the end of matrix b
*/
void append_matrix(struct matrix *a, struct matrix *b){
  int r, c;
  for(r =0; r< a->rows; r++)
    for (c=0; c < a->cols; c++){
      if(b->lastcol == b->cols)
	grow_matrix(b, b->lastcol+100);
      b->m[r][b->lastcol + c]=a->m[r][c];
    }
}
Example #4
0
File: draw.c Project: stuydw/curves
/*======== void add_point() ==========
Inputs:   struct matrix * points
         int x
         int y
         int z 
Returns: 
adds point (x, y, z) to points and increment points.lastcol
if points is full, should call grow on points
====================*/
void add_point( struct matrix * points, int x, int y, int z) {
  if(points->lastcol == points->cols)
    grow_matrix(points,(points->cols)*2);
  points->m[0][points->lastcol] = x;
  points->m[1][points->lastcol] = y;
  points->m[2][points->lastcol] = z;
  points->m[3][points->lastcol] = 1;
  (points->lastcol)++;
}
Example #5
0
/*======== void add_point() ==========
  Inputs: struct matrix * points
  int x
  int y
  int z
  Returns:
  adds point (x, y, z) to points and increment points.lastcol
  if points is full, should call grow on points
  ====================*/
void add_point( struct matrix * points, double x, double y, double z) {
  if ( points->lastcol == points->cols )
    grow_matrix( points, points->lastcol + 100 );
  points->m[0][points->lastcol] = x;
  points->m[1][points->lastcol] = y;
  points->m[2][points->lastcol] = z;
  points->m[3][points->lastcol] = 1;
  points->lastcol++;
}
Example #6
0
File: draw.c Project: stuydw/matrix
/*======== void add_point() ==========
Inputs:   struct matrix * points
int x
int y
int z 
Returns: 
adds point (x, y, z) to points and increment points.lastcol
if points is full, should call grow on points
====================*/
void add_point( struct matrix * points, int x, int y, int z) {
    int lc = points->lastcol;
    if (lc == points->cols)
        grow_matrix(points, points->cols + 10);
    points->m[0][lc] = x;
    points->m[1][lc] = y;
    points->m[2][lc] = z;
    points->m[3][lc] = 1;
    points->lastcol = lc + 1;
}
Example #7
0
/*======== void add_point() ==========
Inputs:   struct matrix * points
         int x
         int y
         int z 
Returns: 
adds point (x, y, z) to points and increment points.lastcol
if points is full, should call grow on points
====================*/
void add_point( struct matrix * points, int x, int y, int z) {
  if (points->lastcol == points->cols) {
    grow_matrix(points, points->lastcol + 10);
  }
  points->m[0][points->lastcol] = x;
  points->m[1][points->lastcol] = y;
  points->m[2][points->lastcol] = z;
  points->m[3][points->lastcol] = 1;
  points->lastcol ++;
}
Example #8
0
void append_matrix(struct matrix *a, struct matrix *b){
  int r,c;
  grow_matrix(a,a->lastcol+ b->lastcol);
  for (c=0; c < b->lastcol; c++){
    for (r=0; r < b->rows; r++){
      a->m[r][a->lastcol]=b->m[r][c];
    }
    a->lastcol = a->lastcol +1;
  }
}
Example #9
0
/*======== void add_point() ==========
Inputs:   struct matrix * points
         int x
         int y
         int z 
Returns: 
adds point (x, y, z) to points and increment points.lastcol
if points is full, should call grow on points
====================*/
void add_point( struct matrix * points, int x, int y, int z) {
	int c = points->cols;
	int l = points->lastcol;
	if(c>=l)
		l=c+1;
	double **m = points->m;
	grow_matrix(points,c+1);
	m[0][c]=x;
	m[1][c]=y;
	m[2][c]=z;
	m[3][c]=1;
}
Example #10
0
void add_point(struct matrix * points, double x, double y, double z) {
    if (points->lastcol >= points->cols - 1) {
        grow_matrix(points, points->cols * 2);
    }
    double **m = points->m;
    int lastcol = points->lastcol;
    m[0][lastcol] = x;
    m[1][lastcol] = y;
    m[2][lastcol] = z;
    m[3][lastcol] = 1;
    ++points->lastcol;
}
Example #11
0
/*======== void add_point() ==========
Inputs:   struct matrix * points
         int x
         int y
         int z 
Returns: 
adds point (x, y, z) to points and increment points.lastcol
if points is full, should call grow on points
====================*/
void add_point( struct matrix * points, int x, int y, int z) {
  if(points->lastcol >= points->cols){
    grow_matrix(points, points->cols * 2); //should double the matrix
  }
  printf("LastCol:%d\n", points->lastcol);
  printf("MaxCol:%d\n", points->cols);
  int lastcol = points->lastcol;
  
  points->m[0][lastcol] = x;
  points->m[1][lastcol] = y;
  points->m[2][lastcol] = z;
  points->m[3][lastcol] = 1;
  
  points->lastcol += 1;
}
Example #12
0
/*-------------- void matrix_mult() --------------
Inputs: struct matrix *a
struct matrix *b
Returns:

a*b -> b
*/
void matrix_mult(struct matrix *a, struct matrix *b) {
  int x;
  int y;
  int z;
  struct matrix * g;
  g = new_matrix(a->rows,b->cols);
  if(a->cols == b->rows){
    for(x = 0;  x < a->rows; x++){
      for(y = 0;  y < b->cols; y++){
	g->m[x][y] = 0;
	for(z=0; z < a->cols; z++){
	  g->m[x][y] += ( (a->m[x][z]) * (b->m[z][y]));
	}
      }
    }
  }
  grow_matrix(a,b->cols);
  copy_matrix(g,a); 
}
Example #13
0
/*======== void add_point() ==========
Inputs:   struct matrix * points
         int x
         int y
         int z 
Returns: 
adds point (x, y, z) to points and increment points.lastcol
if points is full, should call grow on points
====================*/
void add_point( struct matrix * points, int x, int y, int z) {
  /*printf("WHERE ARE U SEG FAULT ft. add_point -1 \n");
  grow_matrix(points, (points->cols) + 1);
  printf("WHERE ARE U SEG FAULT ft. add_point 0 \n");
  int c = points->cols;
  printf("WHERE ARE U SEG FAULT ft. add_point 1 \n");
  points->m[0][c] = x;
  points->m[1][c] = y;
  points->m[2][c] = z;
  points->m[3][c] = 1;
  printf("WHERE ARE U SEG FAULT ft. add_point 2 \n");*/
  if (points->lastcol == points->cols) {
    grow_matrix(points,points->cols + 1);
  }
  //I HAVE NO IDEA WHY I USE LASTCOL INSTEAD OF ?!?!?
  points->m[0][points->lastcol]=x;
  points->m[1][points->lastcol]=y;
  points->m[2][points->lastcol]=z;
  points->m[3][points->lastcol]=1;
  points->lastcol = points->lastcol + 1;
}
Example #14
0
/*======== void add_polygon() ==========
Inputs:   struct matrix *surfaces
         double x0
         double y0
         double z0
         double x1
         double y1
         double z1
         double x2
         double y2
         double z2  
Returns: 
Adds the vertices (x0, y0, z0), (x1, y1, z1)
and (x2, y2, z2) to the polygon matrix. They
define a single triangle surface.

04/16/13 13:05:59
jdyrlandweaver
====================*/
void add_polygon( struct matrix *polygons, 
		  double x0, double y0, double z0, 
		  double x1, double y1, double z1, 
		  double x2, double y2, double z2 ) {
  polygons-> m[0][polygons->lastcol] = x0;
  polygons-> m[1][polygons->lastcol] = y0;
  polygons-> m[2][polygons->lastcol] = z0;
  polygons-> m[3][polygons->lastcol] = 1;
  polygons-> lastcol = lastcol + 1;
  polygons-> m[0][polygons->lastcol] = x1;
  polygons-> m[1][polygons->lastcol] = y1;
  polygons-> m[2][polygons->lastcol] = z1;
  polygons-> m[3][polygons->lastcol] = 1;
  polygons-> lastcol = lastcol + 1;
  polygons-> m[0][polygons->lastcol] = x2;
  polygons-> m[1][polygons->lastcol] = y2;
  polygons-> m[2][polygons->lastcol] = z2;
  polygons-> m[3][polygons->lastcol] = 1;
  polygons-> lastcol = lastcol + 1;

  grow_matrix(polygons,polygons->lastcol+3);
}