Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
vec Struct Reference

vector with 3 floats and some useful methods. More...

#include <geom.hpp>

Inheritance diagram for vec:
plane

Public Member Functions

 vec ()
 a variety of constructor calls is supported More...
 
 vec (int a)
 
 vec (float a)
 
 vec (float a, float b, float c)
 
 vec (int v[3])
 
 vec (const float *v)
 
 vec (const vec2 &v, float z=0)
 
 vec (const vec4 &v)
 
 vec (const ivec &v)
 
 vec (float yaw, float pitch)
 vector constructor which converts yaw and pitch angles to XYZ coordinates More...
 
float & operator[] (int i)
 operators for accessing XYZ vector coordinates More...
 
float operator[] (int i) const
 
vecset (int i, float f)
 
bool operator== (const vec &o) const
 operators for vector comparisn More...
 
bool operator!= (const vec &o) const
 
vecabs ()
 Receive the absolute values of this vec. More...
 
bool iszero () const
 "do all cartesian coordinates (XYZ) of this vector have the value zero?" More...
 
float squaredlen () const
 calculate the squared length of this vector (pythagoras) More...
 
template<class T >
float dot2 (const T &o) const
 dot product (line by line) of 2 dimensions More...
 
float dot (const vec &o) const
 dot product (line by line) of all 3 dimensions More...
 
float absdot (const vec &o) const
 dot product with absolute values. More...
 
vecmul (const vec &o)
 scalar multiplication More...
 
vecmul (float f)
 
vecdiv (const vec &o)
 scalar division More...
 
vecdiv (float f)
 
vecadd (const vec &o)
 scalar sum More...
 
vecadd (float f)
 
vecsub (const vec &o)
 scalar subtraction More...
 
vecsub (float f)
 
vecneg2 ()
 turn XY coordinates into its negative values More...
 
vecneg ()
 turn all 3 (XYZ) coordinates into its negative values More...
 
vecmin (const vec &o)
 vector min/max-comparison and clamp methods More...
 
vecmax (const vec &o)
 
vecmin (float f)
 
vecmax (float f)
 
vecclamp (float f, float h)
 
float magnitude2 () const
 vector's magnitude in XY dimension More...
 
float magnitude () const
 vector's magnitude in all 3 (XYZ) dimensions More...
 
vecnormalize ()
 normalize vector: divide it by its length (magnitude) More...
 
bool isnormalized () const
 "is this vector normalized?" More...
 
float squaredist (const vec &e) const
 distance calculation methods More...
 
float dist (const vec &e) const
 
float dist (const vec &e, vec &t) const
 
float dist2 (const vec &o) const
 
bool reject (const vec &o, float r)
 
template<class A , class B >
veccross (const A &a, const B &b)
 template based vector cross product More...
 
veccross (const vec &o, const vec &a, const vec &b)
 
float scalartriple (const vec &a, const vec &b) const
 scalar triple product can be used to calculate the volume of a 3 dimensional parallelogram More...
 
vecreflectz (float rz)
 vector reflection (around angle or other vectors) More...
 
vecreflect (const vec &n)
 
vecproject (const vec &n)
 vector projection More...
 
vecprojectxydir (const vec &n)
 
vecprojectxy (const vec &n)
 
vecprojectxy (const vec &n, float threshold)
 
veclerp (const vec &b, float t)
 interpolation between two vectors More...
 
veclerp (const vec &a, const vec &b, float t)
 
template<class B >
vecmadd (const vec &a, const B &b)
 
template<class B >
vecmsub (const vec &a, const B &b)
 
vecrescale (float k)
 scale a vector to a certain length More...
 
vecrotate_around_z (float c, float s)
 vector rotation methods More...
 
vecrotate_around_x (float c, float s)
 
vecrotate_around_y (float c, float s)
 
vecrotate_around_z (float angle)
 
vecrotate_around_x (float angle)
 
vecrotate_around_y (float angle)
 
vecrotate_around_z (const vec2 &sc)
 
vecrotate_around_x (const vec2 &sc)
 
vecrotate_around_y (const vec2 &sc)
 
vecrotate (float c, float s, const vec &d)
 
vecrotate (float angle, const vec &d)
 
vecrotate (const vec2 &sc, const vec &d)
 
void orthogonal (const vec &d)
 orthogonal projection More...
 
void orthonormalize (vec &s, vec &t) const
 
template<class T >
bool insidebb (const T &bbmin, const T &bbmax) const
 is vector inside bounding box bounding boxes have a minimal vector and a maximal vector More...
 
template<class T , class U >
bool insidebb (const T &o, U size) const
 
template<class T >
float dist_to_bb (const T &min, const T &max) const
 calculate vector's distance to a bounding box More...
 
template<class T , class S >
float dist_to_bb (const T &o, S size) const
 

Static Public Member Functions

static vec hexcolor (int color)
 

Public Attributes

union {
   struct {
float x
 
float y
 
float z
 
   } 
 
   struct {
float r
 
float g
 
float b
 
   } 
 
float v [3]
 
}; 
 memory union which contains position, color or 3 float values please note that only one of these members can be accessed! More...
 

Friends

std::ostream & operator<< (std::ostream &os, const vec &v)
 Output operator, used for simple << vec << functionality: output of form"(x, y, z)" You may want to set the precision beforehand with std::setprecision() More...
 

Detailed Description

vector with 3 floats and some useful methods.

Constructor & Destructor Documentation

vec::vec ( )
inline

a variety of constructor calls is supported

Referenced by cross(), hexcolor(), madd(), msub(), orthogonal(), orthonormalize(), rotate(), squaredist(), and plane::toplane().

vec::vec ( int  a)
inlineexplicit
vec::vec ( float  a)
inlineexplicit
vec::vec ( float  a,
float  b,
float  c 
)
inline
vec::vec ( int  v[3])
inlineexplicit
vec::vec ( const float *  v)
inlineexplicit
vec::vec ( const vec2 v,
float  z = 0 
)
inlineexplicit
vec::vec ( const vec4 v)
inlineexplicit
vec::vec ( const ivec v)
inlineexplicit
vec::vec ( float  yaw,
float  pitch 
)
inline

vector constructor which converts yaw and pitch angles to XYZ coordinates

Member Function Documentation

vec& vec::abs ( )
inline

Receive the absolute values of this vec.

Referenced by matrix3::abstransform().

float vec::absdot ( const vec o) const
inline

dot product with absolute values.

Referenced by matrix3::abstransposedtransform().

vec& vec::add ( const vec o)
inline

scalar sum

Referenced by physent::abovehead(), matrix3::abstransform(), triangle::add(), game::adddynlights(), addgrasstri(), addmergedverts(), addnormals(), addtris(), ragdolldata::applyrotlimit(), avoidcollision(), BIH::BIH(), blendfogoverlay(), bounce(), model::boundbox(), boxs(), ai::wpcache::build(), animmodel::mesh::buildnorms(), md5::md5mesh::buildverts(), partrenderer::calc(), ragdolldata::calcanimjoint(), calcavatarpos(), animmodel::calcbb(), ragdolldata::calcboundsphere(), calcgeombb(), vertmodel::vertmeshgroup::calctagmatrix(), skelmodel::skeleton::calctags(), animmodel::mesh::calctangents(), calcvert(), mpr::SolidCube::center(), blobrenderer::clip(), decalrenderer::clip(), mpr::collide(), ragdolldata::constraindist(), ai::delselwaypoints(), dist_to_bb(), shadowmaptexture::dorender(), game::drawhudmodel(), game::drawminimap(), drawminimap(), game::collectclientmode::droptoken(), dynlightreaching(), game::dynlighttrack(), editmoveplane(), ellipsecollide(), gui::end(), entautoview(), entpaste(), entselectionbox(), game::explode(), game::explodeeffects(), physent::feetpos(), particleemitter::finalize(), fireballrenderer::finddepthfxranges(), findnormal(), ai::findorientation(), g3d_key(), genclipplanes(), gencubeverts(), generatelightmap(), generatelumel(), gengrassquads(), genpos(), genpos< PT_TRAIL >(), genprefabmesh(), skelmodel::skeleton::genragdollbones(), blobrenderer::gentris(), decalrenderer::gentris(), getentboundingbox(), dualquat::gettranslation(), game::gotoplayer(), game::gotosel(), guessnormals(), guessshadowdir(), physent::headpos(), fpsent::hitpush(), game::movable::hitpush(), game::hudgunorigin(), ragdolldata::init(), skelmodel::skeleton::initragdoll(), interppos(), quat::invertedrotate(), isshadowmapreceiver(), ai::jumpto(), lerpnormal(), lightreaching(), madd(), menuinfrontofplayer(), mmcollide(), mpr::Model::Model(), modifygravity(), ragdolldata::move(), move(), movecamera(), moveplatform(), moveplayer(), moveragdoll(), ai::movewaypoints(), matrix4x3::mul(), game::newbouncer(), noedit(), game::offsetray(), particle_trail(), game::particletrack(), game::predictplayer(), previewblends(), previewlightmapalpha(), ai::process(), rayboxintersect(), raycubepos(), recalcdir(), recomputecamera(), regularshape(), ai::avoidset::remap(), flarerenderer::render(), render3dbox(), game::renderbouncers(), rendereditcursor(), renderellipse(), renderentarrow(), renderentbox(), renderentcone(), game::collectclientmode::rendergame(), renderlightning(), rendermodel(), game::renderplayerpreview(), game::renderprojectiles(), quat::rotate(), varenderer< T >::seedemitter(), seedpos(), seedpos< PT_TRAIL >(), setcammatrix(), setlerpstep(), ragdollskel::setupjoints(), setupsunlight(), setupsurface(), setupsurfaces(), setva(), game::shoot(), game::shorten(), game::shoteffects(), slideagainst(), animmodel::mesh::smoothnorms(), game::spawnbouncer(), game::spawnnextsplinter(), game::spawnsplinters(), blobrenderer::split(), mpr::EntOBB::supportpoint(), mpr::EntCapsule::supportpoint(), mpr::ModelOBB::supportpoint(), mpr::ModelEllipse::supportpoint(), game::swayhudgun(), switchfloor(), threeplaneintersect(), matrix4::transform(), matrix4::transformnormal(), trystepdown(), trystepup(), ragdolldata::tryunstick(), game::updatebouncers(), game::updateprojectiles(), and writeobj().

vec& vec::add ( float  f)
inline

References f().

vec& vec::clamp ( float  f,
float  h 
)
inline

Referenced by linkvslotshader().

template<class A , class B >
vec& vec::cross ( const A &  a,
const B &  b 
)
inline
vec& vec::cross ( const vec o,
const vec a,
const vec b 
)
inline

References cross(), sub(), and vec().

Referenced by cross().

float vec::dist ( const vec e) const
inline
float vec::dist ( const vec e,
vec t 
) const
inline

References magnitude(), and sub().

float vec::dist2 ( const vec o) const
inline

Referenced by regularshape().

template<class T >
float vec::dist_to_bb ( const T &  min,
const T &  max 
) const
inline

calculate vector's distance to a bounding box

References loopi().

Referenced by calcdynlightmask(), dist_to_bb(), findvisiblemms(), and vadist().

template<class T , class S >
float vec::dist_to_bb ( const T &  o,
size 
) const
inline

References add(), and dist_to_bb().

vec& vec::div ( const vec o)
inline
vec& vec::div ( float  f)
inline

References f().

float vec::dot ( const vec o) const
inline
template<class T >
float vec::dot2 ( const T &  o) const
inline

dot product (line by line) of 2 dimensions

Referenced by mpr::EntCylinder::contactface(), mpr::ModelEllipse::contactface(), magnitude2(), and matrix3::transposedtransform().

static vec vec::hexcolor ( int  color)
inlinestatic
template<class T >
bool vec::insidebb ( const T &  bbmin,
const T &  bbmax 
) const
inline

is vector inside bounding box bounding boxes have a minimal vector and a maximal vector

template<class T , class U >
bool vec::insidebb ( const T &  o,
size 
) const
inline
bool vec::isnormalized ( ) const
inline

"is this vector normalized?"

References f(), and squaredlen().

Referenced by calcocclusion().

bool vec::iszero ( ) const
inline
vec& vec::lerp ( const vec b,
float  t 
)
inline
vec& vec::lerp ( const vec a,
const vec b,
float  t 
)
inline
template<class B >
vec& vec::madd ( const vec a,
const B &  b 
)
inline
float vec::magnitude ( ) const
inline
float vec::magnitude2 ( ) const
inline
vec& vec::max ( const vec o)
inline
vec& vec::max ( float  f)
inline

References inexor::rpc::max().

vec& vec::min ( const vec o)
inline

vector min/max-comparison and clamp methods

References inexor::rpc::min().

Referenced by BIH::BIH(), calcshadowmask(), genclipplanes(), and blobrenderer::gentris().

vec& vec::min ( float  f)
inline

References inexor::rpc::min().

template<class B >
vec& vec::msub ( const vec a,
const B &  b 
)
inline
vec& vec::mul ( const vec o)
inline

scalar multiplication

Referenced by matrix3::abstransform(), game::adddynlights(), flarerenderer::addflare(), addmergedverts(), addnormals(), addtris(), ragdolldata::applyrotlimit(), BIH::BIH(), bounce(), boxs3D(), md5::md5mesh::buildverts(), quat::calcangleaxis(), matrix3::calcangleaxis(), ragdolldata::calcanimjoint(), animmodel::calcbb(), dynlight::calccolor(), calcgeombb(), vertmodel::vertmeshgroup::calctagmatrix(), skelmodel::skeleton::calctags(), animmodel::mesh::calctangents(), calcvert(), blobrenderer::clip(), decalrenderer::clip(), mpr::collide(), vertmodel::vertmeshgroup::concattagtransform(), skelmodel::skeleton::concattagtransform(), ragdolldata::constraindist(), ai::delselwaypoints(), shadowmaptexture::dorender(), game::hideandseekclientmode::drawblip(), game::ctfclientmode::drawblip(), game::bombclientmode::drawblip(), game::collectclientmode::drawblip(), game::captureclientmode::drawblips(), drawfogdome(), game::drawhudmodel(), game::drawminimap(), drawminimap(), game::drawteammate(), server::ctfservermode::dropflag(), dynlightreaching(), editmoveplane(), gui::end(), entautoview(), entpaste(), entselectionbox(), game::explodeeffects(), particleemitter::finalize(), fireballrenderer::finddepthfxranges(), findents(), ai::findorientation(), genclipplanes(), gencubeverts(), generatelightmap(), generatelumel(), gengrassquads(), genpos(), genpos< PT_TAPE >(), genprefabmesh(), skelmodel::skeleton::genragdollbones(), genrotpos< PT_PART >(), blobrenderer::gentris(), decalrenderer::gentris(), dualquat::gettranslation(), game::gotoplayer(), game::gotosel(), guessshadowdir(), fpsent::hitpush(), game::movable::hitpush(), game::hudgunorigin(), ragdolldata::init(), skelmodel::skeleton::initragdoll(), interppos(), matrix3::invert(), matrix4x3::invert(), quat::invertedrotate(), isshadowmapreceiver(), lerpnormal(), lightreaching(), madd(), flarerenderer::makelightflares(), menuinfrontofplayer(), mergevslot(), modifygravity(), modifyvelocity(), game::movable::movable(), ragdolldata::move(), movecamera(), moveplayer(), moveragdoll(), game::collectclientmode::movetoken(), msub(), matrix3::mul(), matrix4x3::mul(), matrix3::multranspose(), matrix4x3::multranspose(), game::newbouncer(), noedit(), game::offsetray(), server::parsepacket(), game::parsepositions(), game::particletrack(), game::predictplayer(), previewblends(), previewlightmapalpha(), previewprefab(), server::bombservermode::pushentity(), rayboxintersect(), raycubelos(), raycubepos(), recalcdir(), regularshape(), flarerenderer::render(), game::renderbouncers(), rendereditcursor(), renderentarrow(), renderentcone(), renderlightning(), renderprefab(), game::renderprojectiles(), rendertexturepanel(), renderwater(), rescale(), quat::rotate(), matrix3::rotate_around_x(), matrix4x3::rotate_around_x(), matrix3::rotate_around_y(), matrix4x3::rotate_around_y(), matrix3::rotate_around_z(), matrix4x3::rotate_around_z(), matrix3::scale(), matrix4x3::scale(), plane::scale(), game::selectcrosshair(), game::sendposition(), setcammatrix(), setdynlights(), setlerpstep(), setupcaustics(), ragdollskel::setupjoints(), setupsunlight(), setupsurface(), setupsurfaces(), setva(), game::shoot(), game::shorten(), blobrenderer::split(), game::swayhudgun(), threeplaneintersect(), dualquat::transform(), matrix3::transform(), matrix4::transform(), matrix4x3::transformnormal(), matrix4::transformnormal(), game::triggerplatform(), trystepdown(), trystepup(), game::updatebouncers(), game::updatemovables(), and game::updateprojectiles().

vec& vec::mul ( float  f)
inline

References f().

vec& vec::neg ( )
inline
vec& vec::neg2 ( )
inline

turn XY coordinates into its negative values

vec& vec::normalize ( )
inline
bool vec::operator!= ( const vec o) const
inline
bool vec::operator== ( const vec o) const
inline

operators for vector comparisn

float& vec::operator[] ( int  i)
inline

operators for accessing XYZ vector coordinates

float vec::operator[] ( int  i) const
inline
void vec::orthogonal ( const vec d)
inline
void vec::orthonormalize ( vec s,
vec t 
) const
inline

References dot(), sub(), and vec().

Referenced by generatelumel().

vec& vec::project ( const vec n)
inline

vector projection

References dot().

Referenced by skelmodel::skeleton::calcdeviation(), modifygravity(), slideagainst(), and switchfloor().

vec& vec::projectxy ( const vec n)
inline
vec& vec::projectxy ( const vec n,
float  threshold 
)
inline
vec& vec::projectxydir ( const vec n)
inline

Referenced by projectxy().

vec& vec::reflect ( const vec n)
inline

References dot().

Referenced by ragdolldata::move(), and ragdolldata::updatepos().

vec& vec::reflectz ( float  rz)
inline

vector reflection (around angle or other vectors)

bool vec::reject ( const vec o,
float  r 
)
inline
vec& vec::rescale ( float  k)
inline

scale a vector to a certain length

References f(), magnitude(), and mul().

Referenced by calcavatarpos(), game::newbouncer(), projectxy(), regularshape(), and ragdolldata::tryunstick().

vec& vec::rotate ( float  c,
float  s,
const vec d 
)
inline

References vec().

Referenced by decalrenderer::adddecal().

vec& vec::rotate ( float  angle,
const vec d 
)
inline

References rotate().

Referenced by rotate().

vec& vec::rotate ( const vec2 sc,
const vec d 
)
inline

References rotate().

Referenced by rotate().

vec& vec::rotate_around_x ( float  c,
float  s 
)
inline

Referenced by calcmodelpreviewpos().

vec& vec::rotate_around_x ( float  angle)
inline

References rotate_around_x().

Referenced by rotate_around_x().

vec& vec::rotate_around_x ( const vec2 sc)
inline

References rotate_around_x().

Referenced by rotate_around_x().

vec& vec::rotate_around_y ( float  c,
float  s 
)
inline
vec& vec::rotate_around_y ( float  angle)
inline

References rotate_around_y().

Referenced by rotate_around_y().

vec& vec::rotate_around_y ( const vec2 sc)
inline

References rotate_around_y().

Referenced by rotate_around_y().

vec& vec::rotate_around_z ( float  c,
float  s 
)
inline
vec& vec::rotate_around_z ( float  angle)
inline

References rotate_around_z().

Referenced by rotate_around_z().

vec& vec::rotate_around_z ( const vec2 sc)
inline

References rotate_around_z().

Referenced by rotate_around_z().

float vec::scalartriple ( const vec a,
const vec b 
) const
inline

scalar triple product can be used to calculate the volume of a 3 dimensional parallelogram

Referenced by addcubeverts(), and mpr::collide().

vec& vec::set ( int  i,
float  f 
)
inline

References f().

Referenced by gui::end().

float vec::squaredist ( const vec e) const
inline
float vec::squaredlen ( ) const
inline
vec& vec::sub ( const vec o)
inline

scalar subtraction

Referenced by decalrenderer::adddecal(), flarerenderer::addflare(), addgrasstri(), addlight(), addnormals(), addtris(), ragdolldata::applyrotlimit(), avoidcollision(), BIH::BIH(), bounce(), game::bounced(), brightestlight(), ai::wpcache::build(), animmodel::mesh::buildnorms(), partrenderer::calc(), ragdolldata::calcanimjoint(), calcavatarpos(), animmodel::calcbb(), calcshadowmapbb(), calcshadowmask(), animmodel::mesh::calctangents(), ragdolldata::calctris(), blobrenderer::clip(), decalrenderer::clip(), mpr::collide(), ragdolldata::constraindist(), cross(), damagecompass(), ai::delselwaypoints(), dist(), ai::dointerest(), game::hideandseekclientmode::drawblip(), game::ctfclientmode::drawblip(), game::bombclientmode::drawblip(), game::collectclientmode::drawblip(), game::captureclientmode::drawblips(), game::drawminimap(), drawminimap(), game::drawteammate(), dynlightreaching(), editmoveplane(), ellipseboxcollide(), gui::end(), entautoview(), entselectionbox(), fireballrenderer::finddepthfxranges(), findents(), g3d_key(), genclipplanes(), generatelightmap(), generatelumel(), gengrassquads(), genpos(), genpos< PT_TAPE >(), skelmodel::skeleton::genragdollbones(), decalrenderer::gentris(), getentboundingbox(), dualquat::gettranslation(), guessshadowdir(), game::hudgunorigin(), ragdolldata::init(), ai::jumpto(), lerpnormal(), lightreaching(), linecylinderintersect(), ai::lockon(), flarerenderer::makelightflares(), mmcollide(), mmintersect(), gui::modelpreview(), ragdolldata::move(), moveplayer(), msub(), game::newbouncer(), game::newprojectile(), game::offsetray(), orthonormalize(), platformcollide(), plcollide(), flag::pos(), raycubelos(), raysphereintersect(), regularshape(), flarerenderer::render(), animmodel::part::render(), render3dbox(), rendereditcursor(), renderentradius(), renderlightning(), fireballrenderer::renderpart(), game::renderplayer(), game::bombclientmode::renderplayersposindicator(), game::renderprojectiles(), setdynlights(), setlerpstep(), ragdollskel::setupjoints(), setupsurface(), game::shorten(), animmodel::mesh::smoothnorms(), blobrenderer::split(), triangle::sub(), plane::toplane(), matrix4x3::transposedtransform(), matrix4::transposedtransform(), BIH::triintersect(), trystepup(), game::updatebouncers(), and ragdolldata::updatepos().

vec& vec::sub ( float  f)
inline

References f().

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const vec v 
)
friend

Output operator, used for simple << vec << functionality: output of form"(x, y, z)" You may want to set the precision beforehand with std::setprecision()

Member Data Documentation

union { ... }

memory union which contains position, color or 3 float values please note that only one of these members can be accessed!


The documentation for this struct was generated from the following file: