disable the unrecognized nls and x flags
[AROS-Contrib.git] / Games / XInvaders3D / vec4x1.c
blob534e9c48cad5b93c92ae9bc3af7ed797cdc25cb8
1 /*------------------------------------------------------------------
2 vec4x1.c:
4 XINVADERS 3D - 3d Shoot'em up
5 Copyright (C) 2000 Don Llopis
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program 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
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ------------------------------------------------------------------*/
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <memory.h>
26 #include <math.h>
28 #include "vec4x1.h"
30 /*================================================================*/
32 void Vector_init ( VECTOR4 a )
34 a[0] = a[1] = a[2] = 0.0f;
35 a[3] = 1.0f;
38 /*================================================================*/
40 void Vector_set ( VECTOR4 a, float x, float y, float z )
42 a[0] = x;
43 a[1] = y;
44 a[2] = z;
45 a[3] = 1.0f;
48 /*================================================================*/
50 void Vector_copy ( VECTOR4 a, VECTOR4 b )
52 memcpy ( b, a, sizeof ( VECTOR4 ) );
55 /*================================================================*/
57 void Vector_print ( VECTOR4 a )
59 fprintf ( stderr, "%5.5f %5.5f %5.5f\n", a[0], a[1], a[2] );
62 /*================================================================*/
64 void Vector_negate ( VECTOR4 a )
66 a[0] *= -1.0f;
67 a[1] *= -1.0f;
68 a[2] *= -1.0f;
71 /*================================================================*/
73 void Vector_add ( VECTOR4 a, VECTOR4 b, VECTOR4 c )
75 c[0] = a[0] + b[0];
76 c[1] = a[1] + b[1];
77 c[2] = a[2] + b[2];
80 void Vector_addd ( VECTOR4 a, VECTOR4 b )
82 a[0] = a[0] + b[0];
83 a[1] = a[1] + b[1];
84 a[2] = a[2] + b[2];
87 /*================================================================*/
89 void Vector_sub ( VECTOR4 a, VECTOR4 b, VECTOR4 c )
91 c[0] = a[0] - b[0];
92 c[1] = a[1] - b[1];
93 c[2] = a[2] - b[2];
96 void Vector_subb ( VECTOR4 a, VECTOR4 b )
98 a[0] = a[0] - b[0];
99 a[1] = a[1] - b[1];
100 a[2] = a[2] - b[2];
103 /*================================================================*/
105 void Vector_cross ( VECTOR4 a, VECTOR4 b, VECTOR4 c )
107 c[0] = ( a[1] * b[2] ) - ( a[2] * b[1] );
108 c[1] = ( a[2] * b[0] ) - ( a[0] * b[2] );
109 c[2] = ( a[0] * b[1] ) - ( a[1] * b[0] );
112 /*================================================================*/
114 float Vector_mag ( VECTOR4 a )
116 return (float) sqrt ( ( a[0] * a[0] + a[1] * a[1] + a[2] * a[2] ) );
119 float Vector_mag_squared ( VECTOR4 a )
121 return ( a[0] * a[0] + a[1] * a[1] + a[2] * a[2] );
125 /*================================================================*/
127 float Vector_dist ( VECTOR4 a, VECTOR4 b )
129 float x, y, z;
131 x = b[0] - a[0];
132 y = b[1] - a[1];
133 z = b[2] - a[2];
135 return (float) sqrt ( (x*x) + (y*y) + (z*z) );
138 /*================================================================*/
140 float Vector_dist_squared ( VECTOR4 a, VECTOR4 b )
142 float x, y, z;
144 x = b[0] - a[0];
145 y = b[1] - a[1];
146 z = b[2] - a[2];
148 return ( (x*x) + (y*y) + (z*z) );
151 /*================================================================*/
153 float Vector_dot ( VECTOR4 a, VECTOR4 b )
155 return ( (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) );
158 /*================================================================*/
160 void Vector_norm ( VECTOR4 a )
162 float len;
164 len = (float) sqrt ( (a[0] * a[0]) + (a[1] * a[1]) + (a[2] * a[2]) );
166 a[0] /= len;
167 a[1] /= len;
168 a[2] /= len;
171 /*================================================================*/
173 void Vector_scale ( VECTOR4 a, float s )
175 a[0] *= s;
176 a[1] *= s;
177 a[2] *= s;
180 /*================================================================*/