![]() |
http://www.sim.no http://www.coin3d.org |
00001 #ifndef COIN_SBVEC4S_H 00002 #define COIN_SBVEC4S_H 00003 00004 /**************************************************************************\ 00005 * 00006 * This file is part of the Coin 3D visualization library. 00007 * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License 00011 * ("GPL") version 2 as published by the Free Software Foundation. 00012 * See the file LICENSE.GPL at the root directory of this source 00013 * distribution for additional information about the GNU GPL. 00014 * 00015 * For using Coin with software that can not be combined with the GNU 00016 * GPL, and for taking advantage of the additional benefits of our 00017 * support services, please contact Systems in Motion about acquiring 00018 * a Coin Professional Edition License. 00019 * 00020 * See http://www.coin3d.org/ for more information. 00021 * 00022 * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY. 00023 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org 00024 * 00025 \**************************************************************************/ 00026 00027 #include <Inventor/SbBasic.h> 00028 #include <Inventor/system/inttypes.h> 00029 #ifndef NDEBUG 00030 #include <Inventor/errors/SoDebugError.h> 00031 #endif // !NDEBUG 00032 00033 class SbVec4us; 00034 class SbVec4b; 00035 class SbVec4i32; 00036 00037 class COIN_DLL_API SbVec4s { 00038 public: 00039 SbVec4s(void) { } 00040 SbVec4s(const short v[4]) { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; vec[3] = v[3]; } 00041 SbVec4s(short x, short y, short z, short w) { vec[0] = x; vec[1] = y; vec[2] = z; vec[3] = w; } 00042 explicit SbVec4s(const SbVec4us & v) { setValue(v); } 00043 explicit SbVec4s(const SbVec4b & v) { setValue(v); } 00044 explicit SbVec4s(const SbVec4i32 & v) { setValue(v); } 00045 00046 SbVec4s & setValue(const short v[4]) { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; vec[3] = v[3]; return *this; } 00047 SbVec4s & setValue(short x, short y, short z, short w) { vec[0] = x; vec[1] = y; vec[2] = z; vec[3] = w; return *this; } 00048 SbVec4s & setValue(const SbVec4s & v) { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; vec[3] = v[3]; return *this; } 00049 SbVec4s & setValue(const SbVec4us & v); 00050 SbVec4s & setValue(const SbVec4b & v); 00051 SbVec4s & setValue(const SbVec4i32 & v); 00052 00053 const short * getValue(void) const { return vec; } 00054 void getValue(short & x, short & y, short & z, short & w) const { x = vec[0]; y = vec[1]; z = vec[2]; w = vec[3]; } 00055 00056 short & operator [] (int i) { return vec[i]; } 00057 const short & operator [] (int i) const { return vec[i]; } 00058 00059 int32_t dot(const SbVec4s & v) const { return vec[0] * v[0] + vec[1] * v[1] + vec[2] * v[2] + vec[3] * v[3]; } 00060 void negate(void) { vec[0] = -vec[0]; vec[1] = -vec[1]; vec[2] = -vec[2]; vec[3] = -vec[3]; } 00061 00062 SbVec4s & operator *= (int d) { vec[0] *= d; vec[1] *= d; vec[2] *= d; vec[3] *= d; return *this; } 00063 SbVec4s & operator *= (double d); 00064 SbVec4s & operator /= (int d) { SbDividerChk("SbVec4s::operator/=(int)", d); vec[0] /= d; vec[1] /= d; vec[2] /= d; vec[3] /= d; return *this; } 00065 SbVec4s & operator /= (double d) { SbDividerChk("SbVec4s::operator/=(double)", d); return operator *= (1.0 / d); } 00066 SbVec4s & operator += (const SbVec4s & v) { vec[0] += v[0]; vec[1] += v[1]; vec[2] += v[2]; vec[3] += v[3]; return *this; } 00067 SbVec4s & operator -= (const SbVec4s & v) { vec[0] -= v[0]; vec[1] -= v[1]; vec[2] -= v[2]; vec[3] -= v[3]; return *this; } 00068 SbVec4s operator - (void) const { return SbVec4s(-vec[0], -vec[1], -vec[2], -vec[3]); } 00069 00070 protected: 00071 short vec[4]; 00072 00073 }; // SbVec4s 00074 00075 COIN_DLL_API inline SbVec4s operator * (const SbVec4s & v, int d) { 00076 SbVec4s val(v); val *= d; return val; 00077 } 00078 00079 COIN_DLL_API inline SbVec4s operator * (const SbVec4s & v, double d) { 00080 SbVec4s val(v); val *= d; return val; 00081 } 00082 00083 COIN_DLL_API inline SbVec4s operator * (int d, const SbVec4s & v) { 00084 SbVec4s val(v); val *= d; return val; 00085 } 00086 00087 COIN_DLL_API inline SbVec4s operator * (double d, const SbVec4s & v) { 00088 SbVec4s val(v); val *= d; return val; 00089 } 00090 00091 COIN_DLL_API inline SbVec4s operator / (const SbVec4s & v, int d) { 00092 SbDividerChk("operator/(SbVec4s,int)", d); 00093 SbVec4s val(v); val /= d; return val; 00094 } 00095 00096 COIN_DLL_API inline SbVec4s operator / (const SbVec4s & v, double d) { 00097 SbDividerChk("operator/(SbVec4s,double)", d); 00098 SbVec4s val(v); val /= d; return val; 00099 } 00100 00101 COIN_DLL_API inline SbVec4s operator + (const SbVec4s & v1, const SbVec4s & v2) { 00102 SbVec4s v(v1); v += v2; return v; 00103 } 00104 00105 COIN_DLL_API inline SbVec4s operator - (const SbVec4s & v1, const SbVec4s & v2) { 00106 SbVec4s v(v1); v -= v2; return v; 00107 } 00108 00109 COIN_DLL_API inline int operator == (const SbVec4s & v1, const SbVec4s & v2) { 00110 return ((v1[0] == v2[0]) && (v1[1] == v2[1]) && (v1[2] == v2[2]) && (v1[3] == v2[3])); 00111 } 00112 00113 COIN_DLL_API inline int operator != (const SbVec4s & v1, const SbVec4s & v2) { 00114 return !(v1 == v2); 00115 } 00116 00117 #endif // !COIN_SBVEC4S_H
Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.
Generated on Mon Feb 28 2011 10:11:53 for Coin by Doxygen. 1.7.3