Back to index

radiance  4R0+20100331
Functions | Variables
fvect.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "parser.h"

Go to the source code of this file.

Functions

double normalize (FVECT v)
void fcross (FVECT vres, FVECT v1, FVECT v2)

Variables

static const char RCSid [] = "$Id: fvect.c,v 1.4 2003/02/28 20:11:29 greg Exp $"

Function Documentation

void fcross ( FVECT  vres,
FVECT  v1,
FVECT  v2 
)

Definition at line 39 of file fvect.c.

{
       vres[0] = v1[1]*v2[2] - v1[2]*v2[1];
       vres[1] = v1[2]*v2[0] - v1[0]*v2[2];
       vres[2] = v1[0]*v2[1] - v1[1]*v2[0];
}
double normalize ( FVECT  v)

Definition at line 15 of file fvect.c.

{
       static double  len;
       
       len = DOT(v, v);
       
       if (len <= 0.0)
              return(0.0);
       
       if (len <= 1.0+FTINY && len >= 1.0-FTINY)
              len = 0.5 + 0.5*len; /* first order approximation */
       else
              len = sqrt(len);

       v[0] /= len;
       v[1] /= len;
       v[2] /= len;

       return(len);
}

Variable Documentation

const char RCSid[] = "$Id: fvect.c,v 1.4 2003/02/28 20:11:29 greg Exp $" [static]

Definition at line 2 of file fvect.c.