P
pereges
I have a structure for 'vector'
typedef struct vector_struct
{
double x, y, z;
}vector;
I have a function defined for vectors called "vector_cross" which
basically takes cross product of two vectors
vector *vector_cross( vector *a, vector *b, vector *c )
{
c->x = (a->y * b->z) - (a->z * b->y) ;
c->y = (a->z * b->x) - (a->x * b->z) ;
c->z = (a->x * b->y) - (a->y * b->x) ;
return(c);
}
Now I created a new structure for 'vertex' which is essentially the
same as vector(with x, y, z coordinates).
typedef vector vertex;
Now, will C allow me to use any data of type vertex with the
vector_cross function and other vector functions that I may have
defined ?
typedef struct vector_struct
{
double x, y, z;
}vector;
I have a function defined for vectors called "vector_cross" which
basically takes cross product of two vectors
vector *vector_cross( vector *a, vector *b, vector *c )
{
c->x = (a->y * b->z) - (a->z * b->y) ;
c->y = (a->z * b->x) - (a->x * b->z) ;
c->z = (a->x * b->y) - (a->y * b->x) ;
return(c);
}
Now I created a new structure for 'vertex' which is essentially the
same as vector(with x, y, z coordinates).
typedef vector vertex;
Now, will C allow me to use any data of type vertex with the
vector_cross function and other vector functions that I may have
defined ?