/usr/include/fox-1.6/FXVec4f.h is in libfox-1.6-dev 1.6.50-1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | /********************************************************************************
* *
* S i n g l e - P r e c i s i o n 4 - E l e m e n t V e c t o r *
* *
*********************************************************************************
* Copyright (C) 1994,2006 by Jeroen van der Zijp. All Rights Reserved. *
*********************************************************************************
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*********************************************************************************
* $Id: FXVec4f.h,v 1.32 2006/01/22 17:58:12 fox Exp $ *
********************************************************************************/
#ifndef FXVEC4F_H
#define FXVEC4F_H
namespace FX {
class FXMat4f;
/// Single-precision 4-element vector
class FXAPI FXVec4f {
public:
FXfloat x;
FXfloat y;
FXfloat z;
FXfloat w;
public:
/// Default constructor
FXVec4f(){}
/// Initialize from another vector
FXVec4f(const FXVec4f& v){x=v.x;y=v.y;z=v.z;w=v.w;}
/// Construct with 3-vector and optional scalar
FXVec4f(const FXVec3f& v,FXfloat ww=1.0f){x=v.x;y=v.y;z=v.z;w=ww;}
/// Construct from array of floats
FXVec4f(const FXfloat v[]){x=v[0];y=v[1];z=v[2];w=v[3];}
/// Construct from components
FXVec4f(FXfloat xx,FXfloat yy,FXfloat zz,FXfloat ww=1.0f){x=xx;y=yy;z=zz;w=ww;}
/// Construct from color
FXVec4f(FXColor color);
/// Return a non-const reference to the ith element
FXfloat& operator[](FXint i){return (&x)[i];}
/// Return a const reference to the ith element
const FXfloat& operator[](FXint i) const {return (&x)[i];}
/// Assign color
FXVec4f& operator=(FXColor color);
/// Assignment
FXVec4f& operator=(const FXVec3f& v){x=v.x;y=v.y;z=v.z;w=1.0f;return *this;}
FXVec4f& operator=(const FXVec4f& v){x=v.x;y=v.y;z=v.z;w=v.w;return *this;}
/// Assignment from array of floats
FXVec4f& operator=(const FXfloat v[]){x=v[0];y=v[1];z=v[2];w=v[3];return *this;}
/// Set value from another vector
FXVec4f& set(const FXVec4f& v){x=v.x;y=v.y;z=v.z;w=v.w;return *this;}
/// Set value from array of floats
FXVec4f& set(const FXfloat v[]){x=v[0];y=v[1];z=v[2];w=v[3];return *this;}
/// Set value from components
FXVec4f& set(FXfloat xx,FXfloat yy,FXfloat zz,FXfloat ww){x=xx;y=yy;z=zz;w=ww;return *this;}
/// Assigning operators
FXVec4f& operator*=(FXfloat n){x*=n;y*=n;z*=n;w*=n;return *this;}
FXVec4f& operator/=(FXfloat n){x/=n;y/=n;z/=n;w/=n;return *this;}
FXVec4f& operator+=(const FXVec4f& v){x+=v.x;y+=v.y;z+=v.z;w+=v.w;return *this;}
FXVec4f& operator-=(const FXVec4f& v){x-=v.x;y-=v.y;z-=v.z;w-=v.w;return *this;}
/// Conversion
operator FXfloat*(){return &x;}
operator const FXfloat*() const {return &x;}
operator FXVec3f&(){return *reinterpret_cast<FXVec3f*>(this);}
operator const FXVec3f&() const {return *reinterpret_cast<const FXVec3f*>(this);}
/// Convert to color
operator FXColor() const;
/// Unary
FXVec4f operator+() const { return *this; }
FXVec4f operator-() const { return FXVec4f(-x,-y,-z,-w); }
/// Vector and vector
FXVec4f operator+(const FXVec4f& v) const { return FXVec4f(x+v.x,y+v.y,z+v.z,w+v.w); }
FXVec4f operator-(const FXVec4f& v) const { return FXVec4f(x-v.x,y-v.y,z-v.z,w-v.w); }
/// Vector and matrix
FXVec4f operator*(const FXMat4f& m) const;
/// Scaling
friend inline FXVec4f operator*(const FXVec4f& a,FXfloat n);
friend inline FXVec4f operator*(FXfloat n,const FXVec4f& a);
friend inline FXVec4f operator/(const FXVec4f& a,FXfloat n);
friend inline FXVec4f operator/(FXfloat n,const FXVec4f& a);
/// Dot product
FXfloat operator*(const FXVec4f& v) const { return x*v.x+y*v.y+z*v.z+w*v.w; }
/// Test if zero
bool operator!() const { return x==0.0f && y==0.0f && z==0.0f && w==0.0f; }
/// Equality tests
bool operator==(const FXVec4f& v) const {return x==v.x && y==v.y && z==v.z && w==v.w; }
bool operator!=(const FXVec4f& v) const {return x!=v.x || y!=v.y || z!=v.z || w!=v.w; }
friend inline bool operator==(const FXVec4f& a,FXfloat n);
friend inline bool operator!=(const FXVec4f& a,FXfloat n);
friend inline bool operator==(FXfloat n,const FXVec4f& a);
friend inline bool operator!=(FXfloat n,const FXVec4f& a);
/// Inequality tests
bool operator<(const FXVec4f& v) const { return x<v.x && y<v.y && z<v.z && w<v.w; }
bool operator<=(const FXVec4f& v) const { return x<=v.x && y<=v.y && z<=v.z && w<=v.w; }
bool operator>(const FXVec4f& v) const { return x>v.x && y>v.y && z>v.z && w>v.w; }
bool operator>=(const FXVec4f& v) const { return x>=v.x && y>=v.y && z>=v.z && w>=v.w; }
friend inline bool operator<(const FXVec4f& a,FXfloat n);
friend inline bool operator<=(const FXVec4f& a,FXfloat n);
friend inline bool operator>(const FXVec4f& a,FXfloat n);
friend inline bool operator>=(const FXVec4f& a,FXfloat n);
friend inline bool operator<(FXfloat n,const FXVec4f& a);
friend inline bool operator<=(FXfloat n,const FXVec4f& a);
friend inline bool operator>(FXfloat n,const FXVec4f& a);
friend inline bool operator>=(FXfloat n,const FXVec4f& a);
/// Length and square of length
FXfloat length2() const { return x*x+y*y+z*z+w*w; }
FXfloat length() const { return sqrtf(length2()); }
/// Clamp values of vector between limits
FXVec4f& clamp(FXfloat lo,FXfloat hi){x=FXCLAMP(lo,x,hi);y=FXCLAMP(lo,y,hi);z=FXCLAMP(lo,z,hi);w=FXCLAMP(lo,w,hi);return *this;}
/// Lowest or highest components
friend inline FXVec4f lo(const FXVec4f& a,const FXVec4f& b);
friend inline FXVec4f hi(const FXVec4f& a,const FXVec4f& b);
/// Compute normalized plane equation ax+by+cz+d=0
friend FXAPI FXVec4f plane(const FXVec4f& vec);
friend FXAPI FXVec4f plane(const FXVec3f& vec,FXfloat dist);
friend FXAPI FXVec4f plane(const FXVec3f& vec,const FXVec3f& p);
friend FXAPI FXVec4f plane(const FXVec3f& a,const FXVec3f& b,const FXVec3f& c);
/// Signed distance normalized plane and point
FXfloat distance(const FXVec3f& p) const;
/// Return true if edge a-b crosses plane
bool crosses(const FXVec3f& a,const FXVec3f& b) const;
/// Normalize vector
friend FXAPI FXVec4f normalize(const FXVec4f& v);
/// Save to a stream
friend FXAPI FXStream& operator<<(FXStream& store,const FXVec4f& v);
/// Load from a stream
friend FXAPI FXStream& operator>>(FXStream& store,FXVec4f& v);
};
inline FXVec4f operator*(const FXVec4f& a,FXfloat n){return FXVec4f(a.x*n,a.y*n,a.z*n,a.w*n);}
inline FXVec4f operator*(FXfloat n,const FXVec4f& a){return FXVec4f(n*a.x,n*a.y,n*a.z,n*a.w);}
inline FXVec4f operator/(const FXVec4f& a,FXfloat n){return FXVec4f(a.x/n,a.y/n,a.z/n,a.w/n);}
inline FXVec4f operator/(FXfloat n,const FXVec4f& a){return FXVec4f(n/a.x,n/a.y,n/a.z,n/a.w);}
inline bool operator==(const FXVec4f& a,FXfloat n){return a.x==n && a.y==n && a.z==n && a.w==n;}
inline bool operator!=(const FXVec4f& a,FXfloat n){return a.x!=n || a.y!=n || a.z!=n || a.w!=n;}
inline bool operator==(FXfloat n,const FXVec4f& a){return n==a.x && n==a.y && n==a.z && n==a.w;}
inline bool operator!=(FXfloat n,const FXVec4f& a){return n!=a.x || n!=a.y || n!=a.z || n!=a.w;}
inline bool operator<(const FXVec4f& a,FXfloat n){return a.x<n && a.y<n && a.z<n && a.w<n;}
inline bool operator<=(const FXVec4f& a,FXfloat n){return a.x<=n && a.y<=n && a.z<=n && a.w<=n;}
inline bool operator>(const FXVec4f& a,FXfloat n){return a.x>n && a.y>n && a.z>n && a.w>n;}
inline bool operator>=(const FXVec4f& a,FXfloat n){return a.x>=n && a.y>=n && a.z>=n && a.w>=n;}
inline bool operator<(FXfloat n,const FXVec4f& a){return n<a.x && n<a.y && n<a.z && n<a.w;}
inline bool operator<=(FXfloat n,const FXVec4f& a){return n<=a.x && n<=a.y && n<=a.z && n<=a.w;}
inline bool operator>(FXfloat n,const FXVec4f& a){return n>a.x && n>a.y && n>a.z && n>a.w;}
inline bool operator>=(FXfloat n,const FXVec4f& a){return n>=a.x && n>=a.y && n>=a.z && n>=a.w;}
inline FXVec4f lo(const FXVec4f& a,const FXVec4f& b){return FXVec4f(FXMIN(a.x,b.x),FXMIN(a.y,b.y),FXMIN(a.z,b.z),FXMIN(a.w,b.w));}
inline FXVec4f hi(const FXVec4f& a,const FXVec4f& b){return FXVec4f(FXMAX(a.x,b.x),FXMAX(a.y,b.y),FXMAX(a.z,b.z),FXMAX(a.w,b.w));}
extern FXAPI FXVec4f plane(const FXVec4f& vec);
extern FXAPI FXVec4f plane(const FXVec3f& vec,FXfloat dist);
extern FXAPI FXVec4f plane(const FXVec3f& vec,const FXVec3f& p);
extern FXAPI FXVec4f plane(const FXVec3f& a,const FXVec3f& b,const FXVec3f& c);
extern FXAPI FXVec4f normalize(const FXVec4f& v);
extern FXAPI FXStream& operator<<(FXStream& store,const FXVec4f& v);
extern FXAPI FXStream& operator>>(FXStream& store,FXVec4f& v);
}
#endif
|