Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

vertex.h

Go to the documentation of this file.
00001 /*********************************************************************
00002 * lescegra                                                           *
00003 *                                                                    *
00004 * http://geeky.kicks-ass.org/projects/lescegra.html                  *
00005 *                                                                    *
00006 * Copyright 2003 by Enno Cramer <uebergeek@web.de>                   *
00007 *                                                                    *
00008 * This library is free software; you can redistribute it and/or      *
00009 * modify it under the terms of the GNU Library General Public        *
00010 * License as published by the Free Software Foundation; either       *
00011 * version 2 of the License, or (at your option) any later version.   *
00012 *                                                                    *
00013 * This library is distributed in the hope that it will be useful,    *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  *
00016 * Library General Public License for more details.                   *
00017 *                                                                    *
00018 * You should have received a copy of the GNU Library General Public  *
00019 * License along with this library; if not, write to the Free         *
00020 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
00021 *********************************************************************/
00022 
00023 #ifndef LSG_VERTEX_H
00024 #define LSG_VERTEX_H 1
00025 
00026 /**
00027  * \file  vertex.h
00028  * \brief Vertex (3 dimensional vector)
00029  */
00030 
00031 /**
00032  * \brief 3 dimensional vector
00033  *
00034  * A three dimensional vector
00035  */
00036 typedef float Vertex[3];
00037 
00038 /**
00039  * Assign all three components of a vertex.
00040  * @param dst   The destination vertex
00041  * @param x     The value for the first component
00042  * @param y     The value for the second component
00043  * @param z     The value for the third component
00044  */
00045 void vertex_assign(Vertex dst, float x, float y, float z);
00046 
00047 /**
00048  * Copy a vertex into another.
00049  * @param dst   The destination vertex
00050  * @param src   The source vertex
00051  */
00052 void vertex_copy(Vertex dst, const Vertex src);
00053 
00054 /**
00055  * Add a vertex to another.
00056  * @param dst   The destination vertex
00057  * @param srx   The vertex to add
00058  */
00059 void vertex_add(Vertex dst, const Vertex src);
00060 
00061 /**
00062  * Subtract a vertex from another.
00063  * @param dst   The destination vertex
00064  * @param src   The vertex to subtract
00065  */
00066 void vertex_sub(Vertex dst, const Vertex src);
00067 
00068 /**
00069  * Multiply two vertices component wise.
00070  * @param dst   The destination vertex
00071  * @param src   The vertex to multiply onto dst
00072  */
00073 void vertex_mul(Vertex dst, const Vertex src);
00074 
00075 /**
00076  * Divide two vertices component wise.
00077  * @param dst   The destination vertex
00078  * @param src   The vertex by which to divide dst
00079  */
00080 void vertex_div(Vertex dst, const Vertex src);
00081 
00082 /**
00083  * Compute the component wise minimum of two vertices.
00084  * @param dst   The destination vertex
00085  * @param src   The second vertex
00086  */
00087 void vertex_min(Vertex dst, const Vertex src);
00088 
00089 /**
00090  * Compute the component wise maximum of two vertices.
00091  * @param dst   The destination vertex
00092  * @param src   The second vertex
00093  */
00094 void vertex_max(Vertex dst, const Vertex src);
00095 
00096 /**
00097  * Scale a vertex by a scalar value.
00098  * @param dst   The vertex to scale
00099  * @param scale The scale factor
00100  */
00101 void vertex_scale(Vertex dst, float scale);
00102 
00103 /**
00104  * Compute the dot product of two vertices.
00105  * @param a     The first vertex
00106  * @param b     The second vertex
00107  * @return The dot product of a and b (a * b == |a| * |b| * cos(a, b))
00108  */
00109 float vertex_dot(const Vertex a, const Vertex b);
00110 
00111 /**
00112  * Compute the cross product of two vertices.
00113  * dst = dst x src
00114  * @param dst   The destination vertex and the first factor
00115  * @param src   The second factor
00116  */
00117 void vertex_cross(Vertex dst, const Vertex src);
00118 
00119 /**
00120  * Compute the euclidean length of a vertex.
00121  * @param src   The vertex
00122  * @return The euclidean length of vertex src (|src|)
00123  */
00124 float vertex_length(const Vertex src);
00125 
00126 /**
00127  * Normalize a vertex so that its length is 1.
00128  * @param dst   The vertex to normalize
00129  */
00130 void vertex_normalize(Vertex dst);
00131 
00132 #endif

(c) 2003, by Enno Cramer
generated on 13 Jul 2003
lescegra - doxygen