head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.41; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.01.59; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.54.05; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.22.02; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

# vector.hxx

Go to the documentation of this file.

    00001
    00006 // Written by Curtis Olson, started December 1997.
    00007 //
    00008 // Copyright (C) 1997  Curtis L. Olson  - curt@@infoplane.com
    00009 //
    00010 // This library is free software; you can redistribute it and/or
    00011 // modify it under the terms of the GNU Library General Public
    00012 // License as published by the Free Software Foundation; either
    00013 // version 2 of the License, or (at your option) any later version.
    00014 //
    00015 // This library is distributed in the hope that it will be useful,
    00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00018 // Library General Public License for more details.
    00019 //
    00020 // You should have received a copy of the GNU Library General Public
    00021 // License along with this library; if not, write to the
    00022 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00023 // Boston, MA  02111-1307, USA.
    00024 //
    00025 // $Id: vector.hxx,v 1.8 2001/05/15 19:26:23 curt Exp $
    00026
    00027
    00028 #ifndef _VECTOR_HXX
    00029 #define _VECTOR_HXX
    00030
    00031
    00032 #ifndef __cplusplus
    00033 # error This library requires C++
    00034 #endif
    00035
    00036 #include <simgear/compiler.h>
    00037
    00038 #include <plib/sg.h>
    00039
    00040
    00048 inline void sgmap_vec_onto_cur_surface_plane( sgVec3 normal,
    00049                                               sgVec3 v0,
    00050                                               sgVec3 vec,
    00051                                               sgVec3 result )
    00052 {
    00053     sgVec3 u1, v, tmp;
    00054
    00055     // calculate a vector "u1" representing the shortest distance from
    00056     // the plane specified by normal and v0 to a point specified by
    00057     // "vec".  "u1" represents both the direction and magnitude of
    00058     // this desired distance.
    00059
    00060     // u1 = ( (normal <dot> vec) / (normal <dot> normal) ) * normal
    00061
    00062     sgScaleVec3( u1,
    00063                  normal,
    00064                  ( sgScalarProductVec3(normal, vec) /
    00065                    sgScalarProductVec3(normal, normal)
    00066                    )
    00067                  );
    00068
    00069     // printf("  vec = %.2f, %.2f, %.2f\n", vec[0], vec[1], vec[2]);
    00070     // printf("  v0 = %.2f, %.2f, %.2f\n", v0[0], v0[1], v0[2]);
    00071     // printf("  u1 = %.2f, %.2f, %.2f\n", u1[0], u1[1], u1[2]);
    00072
    00073     // calculate the vector "v" which is the vector "vec" mapped onto
    00074     // the plane specified by "normal" and "v0".
    00075
    00076     // v = v0 + vec - u1
    00077
    00078     sgAddVec3(tmp, v0, vec);
    00079     sgSubVec3(v, tmp, u1);
    00080     // printf("  v = %.2f, %.2f, %.2f\n", v[0], v[1], v[2]);
    00081
    00082     // Calculate the vector "result" which is "v" - "v0" which is a
    00083     // directional vector pointing from v0 towards v
    00084
    00085     // result = v - v0
    00086
    00087     sgSubVec3(result, v, v0);
    00088     // printf("  result = %.2f, %.2f, %.2f\n",
    00089     // result[0], result[1], result[2]);
    00090 }
    00091
    00092
    00098 inline void sgCopyNegateVec4( sgVec4 dst, sgVec4 src )
    00099 {
    00100         dst [ 0 ] = -src [ 0 ] ;
    00101         dst [ 1 ] = -src [ 1 ] ;
    00102         dst [ 2 ] = -src [ 2 ] ;
    00103         dst [ 3 ] = -src [ 3 ] ;
    00104 }
    00105
    00114 void sgClosestPointToLine( sgVec3 p1, const sgVec3 p, const sgVec3 p0,
    00115                            const sgVec3 d );
    00116
    00125 void sgdClosestPointToLine( sgdVec3 p1, const sgdVec3 p, const sgdVec3 p0,
    00126                             const sgdVec3 d );
    00127
    00137 double sgClosestPointToLineDistSquared( const sgVec3 p, const sgVec3 p0,
    00138                                         const sgVec3 d );
    00139
    00149 double sgdClosestPointToLineDistSquared( const sgdVec3 p, const sgdVec3 p0,
    00150                                          const sgdVec3 d );
    00151
    00161 void sgPostMultMat4ByTransMat4( sgMat4 src, const sgVec3 trans );
    00162
    00163
    00164 #endif // _VECTOR_HXX
    00165
    00166

@ 1.3 log @Oops, try again. @ text @d116 1 a116 1