home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1992-1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- //////////////////////////////////////////////////////////////////////
- // MiscMath.h - miscellaneous math routines
- //////////////////////////////////////////////////////////////////////
-
- #ifndef MISCMATH_H
- #define MISCMATH_H
-
- #include "Defines.h"
-
- // Anything less than this is considered zero
- const float EPSILON = .0001;
-
- Boolean equal(const float, const float);
-
- // returns the legth of v1 which is parallel to v2
- float parallel_length(const SbVec3f v1, const SbVec3f v2);
-
- // projects v1 onto v2
- SbVec3f project(const SbVec3f v1, const SbVec3f v2);
-
- // returns angle in radians b/w the vectors
- float angle_between(const SbVec3f v1, const SbVec3f v2);
-
- // returns the distance of the point to the vector which begins
- // at origin
- float point_vec_distance(SbVec3f point, SbVec3f vec, SbVec3f origin);
-
-
- // are two points on the same side of a line
- // straight outta Sedgewick's Algorithms
- // XXX Assuming X-Z plane.
- Boolean same_side(SbVec3f p1, SbVec3f p2, SbLine line);
-
-
- // Is a point within a convex polygon?
- // The points of the quat should be ordered counter-clockwise.
- // XXX Only looks in X-Z plane.
- Boolean point_within(SbVec3f poly[], int num_verts, SbVec3f point);
-
-
- inline void print_vec(const SbVec3f v)
- {
- printf("%f %f %f\n",v[0],v[1],v[2]);
- }
-
-
-
- #endif
-