home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / demos / audio / drive / MiscMath.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.0 KB  |  65 lines

  1. /*
  2.  * Copyright 1992-1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. //////////////////////////////////////////////////////////////////////
  18. // MiscMath.h - miscellaneous math routines
  19. //////////////////////////////////////////////////////////////////////
  20.  
  21. #ifndef MISCMATH_H
  22. #define MISCMATH_H
  23.  
  24. #include "Defines.h"
  25.  
  26. // Anything less than this is considered zero
  27. const float EPSILON = .0001;
  28.  
  29. Boolean equal(const float, const float);
  30.     
  31. // returns the legth of v1 which is parallel to v2
  32. float parallel_length(const SbVec3f v1, const SbVec3f v2);
  33.  
  34. // projects v1 onto v2
  35. SbVec3f project(const SbVec3f v1, const SbVec3f v2);
  36.  
  37. // returns angle in radians b/w the vectors
  38. float angle_between(const SbVec3f v1, const SbVec3f v2);
  39.  
  40. // returns the distance of the point to the vector which begins
  41. // at origin
  42. float point_vec_distance(SbVec3f point, SbVec3f vec, SbVec3f origin);
  43.  
  44.  
  45. // are two points on the same side of a line
  46. // straight outta Sedgewick's Algorithms
  47. // XXX Assuming X-Z plane.
  48. Boolean same_side(SbVec3f p1, SbVec3f p2, SbLine line);
  49.  
  50.  
  51. // Is a point within a convex polygon?
  52. // The points of the quat should be ordered counter-clockwise.
  53. // XXX Only looks in X-Z plane.
  54. Boolean point_within(SbVec3f poly[], int num_verts, SbVec3f point);
  55.  
  56.  
  57. inline void print_vec(const SbVec3f v)
  58. {
  59.     printf("%f %f %f\n",v[0],v[1],v[2]);
  60. }
  61.  
  62.  
  63.  
  64. #endif
  65.