blitz Version 0.9
|
00001 /*************************************************************************** 00002 * blitz/tvcross.h Cross product of TinyVector<N,3>'s 00003 * 00004 * $Id: tvcross.h,v 1.4 2003/12/11 03:44:22 julianc Exp $ 00005 * 00006 * Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> 00007 * 00008 * This program is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU General Public License 00010 * as published by the Free Software Foundation; either version 2 00011 * of the License, or (at your option) any later version. 00012 * 00013 * This program 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 00016 * GNU General Public License for more details. 00017 * 00018 * Suggestions: blitz-dev@oonumerics.org 00019 * Bugs: blitz-bugs@oonumerics.org 00020 * 00021 * For more information, please see the Blitz++ Home Page: 00022 * http://oonumerics.org/blitz/ 00023 * 00024 ***************************************************************************/ 00025 00026 #ifndef BZ_TVCROSS_H 00027 #define BZ_TVCROSS_H 00028 00029 #ifndef BZ_TINYVEC_H 00030 #error <blitz/tvcross.h> must be included via <blitz/tinyvec.h> 00031 #endif 00032 00033 BZ_NAMESPACE(blitz) 00034 00035 /* 00036 * cross product. 00037 * 00038 * NEEDS_WORK: - cross product of two different vector types 00039 * - cross product involving expressions 00040 */ 00041 00042 template<typename T_numtype> 00043 TinyVector<T_numtype,3> cross(const TinyVector<T_numtype,3>& x, 00044 const TinyVector<T_numtype,3>& y) 00045 { 00046 return TinyVector<T_numtype,3>(x[1]*y[2] - y[1]*x[2], 00047 y[0]*x[2] - x[0]*y[2], x[0]*y[1] - y[0]*x[1]); 00048 } 00049 00050 00051 BZ_NAMESPACE_END 00052 00053 #endif // BZ_TVCROSS_H