![]() |
http://www.sim.no http://www.coin3d.org |
00001 #ifndef COIN_SBVEC2B_H 00002 #define COIN_SBVEC2B_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 SbVec2ub; 00034 class SbVec2s; 00035 class SbVec2i32; 00036 00037 class COIN_DLL_API SbVec2b { 00038 public: 00039 SbVec2b(void) { } 00040 SbVec2b(const int8_t v[2]) { vec[0] = v[0]; vec[1] = v[1]; } 00041 SbVec2b(int8_t x, int8_t y) { vec[0] = x; vec[1] = y; } 00042 explicit SbVec2b(const SbVec2ub & v) { setValue(v); } 00043 explicit SbVec2b(const SbVec2s & v) { setValue(v); } 00044 explicit SbVec2b(const SbVec2i32 & v) { setValue(v); } 00045 00046 SbVec2b & setValue(const int8_t v[2]) { vec[0] = v[0]; vec[1] = v[1]; return *this; } 00047 SbVec2b & setValue(int8_t x, int8_t y) { vec[0] = x; vec[1] = y; return *this; } 00048 SbVec2b & setValue(const SbVec2ub & v); 00049 SbVec2b & setValue(const SbVec2s & v); 00050 SbVec2b & setValue(const SbVec2i32 & v); 00051 00052 const int8_t * getValue(void) const { return vec; } 00053 void getValue(int8_t & x, int8_t & y) const { x = vec[0]; y = vec[1]; } 00054 00055 int8_t & operator [] (int i) { return vec[i]; } 00056 const int8_t & operator [] (int i) const { return vec[i]; } 00057 00058 int32_t dot(SbVec2b v) const { return vec[0] * v[0] + vec[1] * v[1]; } 00059 void negate(void) { vec[0] = -vec[0]; vec[1] = -vec[1]; } 00060 00061 SbVec2b & operator *= (int d) { vec[0] *= d; vec[1] *= d; return *this; } 00062 SbVec2b & operator *= (double d); 00063 SbVec2b & operator /= (int d) { SbDividerChk("SbVec2b::operator/=(int)", d); vec[0] /= d; vec[1] /= d; return *this; } 00064 SbVec2b & operator /= (double d) { SbDividerChk("SbVec2b::operator/=(double)", d); return operator *= (1.0 / d); } 00065 SbVec2b & operator += (SbVec2b v) { vec[0] += v[0]; vec[1] += v[1]; return *this; } 00066 SbVec2b & operator -= (SbVec2b v) { vec[0] -= v[0]; vec[1] -= v[1]; return *this; } 00067 SbVec2b operator - (void) const { return SbVec2b(-vec[0], -vec[1]); } 00068 00069 protected: 00070 int8_t vec[2]; 00071 00072 }; // SbVec2b 00073 00074 COIN_DLL_API inline SbVec2b operator * (SbVec2b v, int d) { 00075 SbVec2b val(v); val *= d; return val; 00076 } 00077 00078 COIN_DLL_API inline SbVec2b operator * (SbVec2b v, double d) { 00079 SbVec2b val(v); val *= d; return val; 00080 } 00081 00082 COIN_DLL_API inline SbVec2b operator * (int d, SbVec2b v) { 00083 SbVec2b val(v); val *= d; return val; 00084 } 00085 00086 COIN_DLL_API inline SbVec2b operator * (double d, SbVec2b v) { 00087 SbVec2b val(v); val *= d; return val; 00088 } 00089 00090 COIN_DLL_API inline SbVec2b operator / (SbVec2b v, int d) { 00091 SbDividerChk("operator/(SbVec2b,int)", d); 00092 SbVec2b val(v); val /= d; return val; 00093 } 00094 00095 COIN_DLL_API inline SbVec2b operator / (SbVec2b v, double d) { 00096 SbDividerChk("operator/(SbVec2b,double)", d); 00097 SbVec2b val(v); val /= d; return val; 00098 } 00099 00100 COIN_DLL_API inline SbVec2b operator + (SbVec2b v1, SbVec2b v2) { 00101 SbVec2b v(v1); v += v2; return v; 00102 } 00103 00104 COIN_DLL_API inline SbVec2b operator - (SbVec2b v1, SbVec2b v2) { 00105 SbVec2b v(v1); v -= v2; return v; 00106 } 00107 00108 COIN_DLL_API inline int operator == (SbVec2b v1, SbVec2b v2) { 00109 return ((v1[0] == v2[0]) && (v1[1] == v2[1])); 00110 } 00111 00112 COIN_DLL_API inline int operator != (SbVec2b v1, SbVec2b v2) { 00113 return !(v1 == v2); 00114 } 00115 00116 #endif // !COIN_SBVEC2B_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