root/trunk/thune/math3d.h

Revision 550, 2.3 kB (checked in by krobillard, 7 weeks ago)

Thune:

  • 8-bit string encoding is now Latin-1.
  • Now using WELL512a generator for random numbers.
  • Added hash-map datatype. List datatype can now be disabled in config.
  • Added project-point, remap.
  • Unique & fill now handle vector!.
  • File port 'read now retuns none when end of file reached.

Thune-GL:

  • Added draw-prog! & vertex-buffer! datatypes.
  • Display now accepts /fullscreen option.
  • Added particle-sim dialect.
Line 
1#ifndef MATH3D_H
2#define MATH3D_H
3/*============================================================================
4    Thune Interpreter
5    Copyright (C) 2005-2006  Karl Robillard
6
7    This library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Lesser General Public
9    License as published by the Free Software Foundation; either
10    version 2.1 of the License, or (at your option) any later version.
11
12    This library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Lesser General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with this library; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20===========================================================================*/
21
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27
28#define UR_PI           3.14159265358979323846
29#define degToRad(deg)   ((UR_PI/180.0)*(double)(deg))
30#define radToDeg(rad)   ((180.0/UR_PI)*(double)(rad))
31
32
33/* Matrix functions */
34
35void ur_loadIdentity( float* );
36void ur_loadRotation( float* mat, const float* axis, float radians );
37void ur_matrixMult( const float* a, const float* b, float* result );
38void ur_transLocal( float* mat, float x, float y, float z );
39void ur_matrixTranspose( float* mat, const float* a );
40void ur_matrixInverse( float* mat, const float* a );
41
42
43/* Vector functions */
44
45float ur_distance( const float* vecA, const float* vecB );
46void  ur_transform( float* pnt, const float* mat );
47void  ur_transform3x3( float* pnt, const float* mat );
48void  ur_reflect( const float* a, const float* b, float* result );
49void  ur_lineToPoint( const float* a, const float* b, const float* pnt,
50                      float* vec );
51void  ur_normalize( float* vec );
52
53#define ur_dot(a,b)  ((a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]))
54
55#define ur_cross(a,b,res) \
56    res[0] = (a[1] * b[2]) - (a[2] * b[1]); \
57    res[1] = (a[2] * b[0]) - (a[0] * b[2]); \
58    res[2] = (a[0] * b[1]) - (a[1] * b[0])
59
60#define ur_lengthSq(a)  ((a[0] * a[0]) + (a[1] * a[1]) + (a[2] * a[2]))
61
62
63#ifdef __cplusplus
64}
65#endif
66
67
68#endif  /* MATH3D_H */
Note: See TracBrowser for help on using the browser.