1.1 --- a/plugins/include/vector.inc Fri Jul 11 06:51:21 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,188 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
1.8 - * =============================================================================
1.9 - *
1.10 - * This file is part of the SourceMod/SourcePawn SDK.
1.11 - *
1.12 - * This program is free software; you can redistribute it and/or modify it under
1.13 - * the terms of the GNU General Public License, version 3.0, as published by the
1.14 - * Free Software Foundation.
1.15 - *
1.16 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.17 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.18 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.19 - * details.
1.20 - *
1.21 - * You should have received a copy of the GNU General Public License along with
1.22 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.23 - *
1.24 - * As a special exception, AlliedModders LLC gives you permission to link the
1.25 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.26 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.27 - * by the Valve Corporation. You must obey the GNU General Public License in
1.28 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.29 - * this exception to all derivative works. AlliedModders LLC defines further
1.30 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.31 - * or <http://www.sourcemod.net/license.php>.
1.32 - *
1.33 - * Version: $Id$
1.34 - */
1.35 -
1.36 -#if defined _vector_included
1.37 - #endinput
1.38 -#endif
1.39 -#define _vector_included
1.40 -
1.41 -/**
1.42 - * Calculates a vector's length.
1.43 - *
1.44 - * @param vec Vector.
1.45 - * @param squared If true, the result will be squared (for optimization).
1.46 - * @return Vector length (magnitude).
1.47 - */
1.48 -native Float:GetVectorLength(const Float:vec[3], bool:squared=false);
1.49 -
1.50 -/**
1.51 - * Calculates the distance between two vectors.
1.52 - *
1.53 - * @param vec1 First vector.
1.54 - * @param vec2 Second vector.
1.55 - * @param squared If true, the result will be squared (for optimization).
1.56 - * @return Vector distance.
1.57 - */
1.58 -native Float:GetVectorDistance(const Float:vec1[3], const Float:vec2[3], bool:squared=false);
1.59 -
1.60 -/**
1.61 - * Calculates the dot product of two vectors.
1.62 - *
1.63 - * @param vec1 First vector.
1.64 - * @param vec2 Second vector.
1.65 - * @return Dot product of the two vectors.
1.66 - */
1.67 -native Float:GetVectorDotProduct(const Float:vec1[3], const Float:vec2[3]);
1.68 -
1.69 -/**
1.70 - * Computes the cross product of two vectors. Any input array can be the same
1.71 - * as the output array.
1.72 - *
1.73 - * @param vec1 First vector.
1.74 - * @param vec2 Second vector.
1.75 - * @param result Resultant vector.
1.76 - * @noreturn
1.77 - */
1.78 -native GetVectorCrossProduct(const Float:vec1[3], const Float:vec2[3], Float:result[3]);
1.79 -
1.80 -/**
1.81 - * Normalizes a vector. The input array can be the same as the output array.
1.82 - *
1.83 - * @param vec Vector.
1.84 - * @param result Resultant vector.
1.85 - * @return Vector length.
1.86 - */
1.87 -native Float:NormalizeVector(const Float:vec[3], Float:result[3]);
1.88 -
1.89 -/**
1.90 - * Returns vectors in the direction of an angle.
1.91 - *
1.92 - * @param angle Angle.
1.93 - * @param fwd Forward vector buffer or NULL_VECTOR.
1.94 - * @param right Right vector buffer or NULL_VECTOR.
1.95 - * @param up Up vector buffer or NULL_VECTOR.
1.96 - * @noreturn
1.97 - */
1.98 -native GetAngleVectors(const Float:angle[3], Float:fwd[3], Float:right[3], Float:up[3]);
1.99 -
1.100 -/**
1.101 - * Returns angles from a vector.
1.102 - *
1.103 - * @param vec Vector.
1.104 - * @param angle Angle buffer.
1.105 - * @noreturn
1.106 - */
1.107 -native GetVectorAngles(const Float:vec[3], Float:angle[3]);
1.108 -
1.109 -/**
1.110 - * Returns direction vectors from a vector.
1.111 - *
1.112 - * @param vec Vector.
1.113 - * @param right Right vector buffer or NULL_VECTOR.
1.114 - * @param up Up vector buffer or NULL_VECTOR.
1.115 - * @noreturn
1.116 - */
1.117 -native GetVectorVectors(const Float:vec[3], Float:right[3], Float:up[3]);
1.118 -
1.119 -/**
1.120 - * Adds two vectors. It is safe to use either input buffer as an output
1.121 - * buffer.
1.122 - *
1.123 - * @param vec1 First vector.
1.124 - * @param vec2 Second vector.
1.125 - * @param result Result buffer.
1.126 - * @noreturn
1.127 - */
1.128 -stock AddVectors(const Float:vec1[3], const Float:vec2[3], Float:result[3])
1.129 -{
1.130 - result[0] = vec1[0] + vec2[0];
1.131 - result[1] = vec1[1] + vec2[1];
1.132 - result[2] = vec1[2] + vec2[2];
1.133 -}
1.134 -
1.135 -/**
1.136 - * Subtracts a vector from another vector. It is safe to use either input
1.137 - * buffer as an output buffer.
1.138 - *
1.139 - * @param vec1 First vector.
1.140 - * @param vec2 Second vector to subtract from first.
1.141 - * @param result Result buffer.
1.142 - * @noreturn
1.143 - */
1.144 -stock SubtractVectors(const Float:vec1[3], const Float:vec2[3], Float:result[3])
1.145 -{
1.146 - result[0] = vec1[0] - vec2[0];
1.147 - result[1] = vec1[1] - vec2[1];
1.148 - result[2] = vec1[2] - vec2[2];
1.149 -}
1.150 -
1.151 -/**
1.152 - * Scales a vector.
1.153 - *
1.154 - * @param vec Vector.
1.155 - * @param scale Scale value.
1.156 - * @noreturn
1.157 - */
1.158 -stock ScaleVector(Float:vec[3], Float:scale)
1.159 -{
1.160 - vec[0] *= scale;
1.161 - vec[1] *= scale;
1.162 - vec[2] *= scale;
1.163 -}
1.164 -
1.165 -/**
1.166 - * Negatives a vector.
1.167 - *
1.168 - * @param vec Vector.
1.169 - * @noreturn
1.170 - */
1.171 -stock NegateVector(Float:vec[3])
1.172 -{
1.173 - vec[0] = -vec[0];
1.174 - vec[1] = -vec[1];
1.175 - vec[2] = -vec[2];
1.176 -}
1.177 -
1.178 -/**
1.179 - * Builds a vector from two points by subtracting the points.
1.180 - *
1.181 - * @param pt1 First point (to be subtracted from the second).
1.182 - * @param pt2 Second point.
1.183 - * @param output Output vector buffer.
1.184 - * @noreturn
1.185 - */
1.186 -stock MakeVectorFromPoints(const Float:pt1[3], const Float:pt2[3], Float:output[3])
1.187 -{
1.188 - output[0] = pt2[0] - pt1[0];
1.189 - output[1] = pt2[1] - pt1[1];
1.190 - output[2] = pt2[2] - pt1[2];
1.191 -}