home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
vis-ftp.cs.umass.edu
/
vis-ftp.cs.umass.edu.tar
/
vis-ftp.cs.umass.edu
/
pub
/
Software
/
ASCENDER
/
ascendMar8.tar
/
UMass
/
BuildingFinder
/
Staging
/
math.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-04-12
|
2KB
|
94 lines
/*----------------------------------------------------------------------------
math.c
A couple of vector/matrix operators.
Author: Christopher Jaynes
Date : Jan. 28, 1995
RADIUS Project.
-----------------------------------------------------------------------------*/
#include "../polygons.h"
#include "rcde_types.h"
extern c_handle make_image();
extern c_handle push_image();
extern c_handle_1_int_3* pick_a_pane();
struct c_handle_1_int_3* pane_choice;
struct c_handle_1_int_2* image_choice;
void vector_matrix_multiply(Point *p, RotMatrix m);
void matrix_multiply(RotMatrix m1, RotMatrix m2, RotMatrix result);
void vector_matrix_multiply(Point *p, RotMatrix m)
{
Point temp;
temp.x = (m[0][0] * p->x +
m[1][0] * p->y +
m[2][0] * p->z +
m[3][0] * p->r);
temp.y = (m[0][1] * p->x +
m[1][1] * p->y +
m[2][1] * p->z +
m[3][1] * p->r);
temp.z = (m[0][2] * p->x +
m[1][2] * p->y +
m[2][2] * p->z +
m[3][2] * p->r);
temp.r = (m[0][3] * p->x +
m[1][3] * p->y +
m[2][3] * p->z +
m[3][3] * p->r);
p->x = temp.x;
p->y = temp.y;
p->z = temp.z;
p->r = temp.r;
}
void matrix_multiply(RotMatrix m1, RotMatrix m2, RotMatrix result)
{
int i;
Point vec;
for (i=0; i < 4; i++) {
vec.x = m1[i][0];
vec.y = m1[i][1];
vec.z = m1[i][2];
vec.r = m1[i][3];
vector_matrix_multiply(&vec,m2);
result[i][0] = vec.x;
result[i][1] = vec.y;
result[i][2] = vec.z;
result[i][3] = vec.r;
}
}
double
distance(double x1, double y1, double x2, double y2)
{
double result;
double sqrt();
result = sqrt( (double) (SQ(x1-x2) + SQ(y1-y2) ));
return( result );
}