2002-08-17 05:27:34 +00:00
|
|
|
/*
|
|
|
|
math.h
|
|
|
|
|
|
|
|
Built-in math function definitions
|
|
|
|
|
|
|
|
Copyright (C) 2002 Bill Currie <taniwha@quakeforge.net>
|
|
|
|
Copyright (C) 2002 Jeff Teunissen <deek@quakeforge.net>
|
|
|
|
|
|
|
|
This file is part of the Ruamoko Standard Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or (at
|
|
|
|
your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
2002-08-15 21:00:51 +00:00
|
|
|
#ifndef __ruamoko_math_h
|
|
|
|
#define __ruamoko_math_h
|
2002-08-15 06:56:37 +00:00
|
|
|
|
2002-08-17 05:27:34 +00:00
|
|
|
/*
|
|
|
|
random
|
2002-08-15 06:56:37 +00:00
|
|
|
|
2002-08-17 05:27:34 +00:00
|
|
|
Generate a random number such that 0 <= num <= 1 (0 to 1 inclusive)
|
|
|
|
*/
|
2002-08-15 06:56:37 +00:00
|
|
|
@extern float () random;
|
2002-08-17 05:27:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
ftoi
|
|
|
|
|
|
|
|
Returns the integer component of f
|
|
|
|
*/
|
2002-08-15 06:56:37 +00:00
|
|
|
@extern integer (float f) ftoi;
|
2002-08-17 05:27:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
itof
|
|
|
|
|
|
|
|
Returns the float representation of i
|
|
|
|
*/
|
2002-08-15 06:56:37 +00:00
|
|
|
@extern float (integer i) itof;
|
2002-08-17 05:27:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
rint
|
|
|
|
|
|
|
|
Rounds v to the nearest integer value and returns it.
|
|
|
|
rint() does not change the type.
|
|
|
|
*/
|
2002-08-15 06:56:37 +00:00
|
|
|
@extern float (float v) rint;
|
2002-08-17 05:27:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
floor
|
|
|
|
|
|
|
|
Returns v, rounded down to the next lower integer
|
|
|
|
*/
|
2002-08-15 06:56:37 +00:00
|
|
|
@extern float (float v) floor;
|
2002-08-17 05:27:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
ceil
|
|
|
|
|
|
|
|
Returns v, rounded up to the next highest integer
|
|
|
|
*/
|
2002-08-15 06:56:37 +00:00
|
|
|
@extern float (float v) ceil;
|
2002-08-17 05:27:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
fabs
|
|
|
|
|
|
|
|
Returns the absolute value of v
|
|
|
|
*/
|
2002-08-15 06:56:37 +00:00
|
|
|
@extern float (float f) fabs;
|
2002-08-17 05:27:34 +00:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* VECTORS *
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
@extern vector v_forward, v_up, v_right;
|
|
|
|
|
|
|
|
/*
|
|
|
|
makevectors
|
|
|
|
|
|
|
|
Set v_forward, v_up, v_right global vectors from the vector ang
|
|
|
|
*/
|
|
|
|
@extern void (vector ang) makevectors;
|
|
|
|
|
|
|
|
/*
|
|
|
|
normalize
|
|
|
|
|
|
|
|
Transform vector v into a unit vector (a vector with a length of 1).
|
|
|
|
The direction is not changed, except for (possible) roundoff errors.
|
|
|
|
*/
|
|
|
|
@extern vector (vector v) normalize;
|
|
|
|
|
|
|
|
/*
|
|
|
|
vlen
|
|
|
|
|
|
|
|
Return the length of vector v
|
|
|
|
*/
|
|
|
|
@extern float (vector v) vlen;
|
|
|
|
|
|
|
|
/*
|
|
|
|
vectoyaw
|
|
|
|
|
|
|
|
Returns the yaw angle ("bearing"), in degrees, associated with vector v.
|
|
|
|
*/
|
|
|
|
@extern float (vector v) vectoyaw;
|
|
|
|
|
|
|
|
/*
|
|
|
|
vectoangles
|
|
|
|
|
|
|
|
Returns a vector 'pitch yaw 0' corresponding to vector v.
|
|
|
|
*/
|
2002-08-15 06:56:37 +00:00
|
|
|
@extern vector (vector v) vectoangles;
|
|
|
|
|
2002-08-17 05:27:34 +00:00
|
|
|
#endif //__ruamoko_math_h
|