[DOC] reduce doxygen warning

This commit is contained in:
Edouard DUPIN 2016-04-01 22:49:58 +02:00
parent 67c8b1b932
commit dc853d574f
39 changed files with 1197 additions and 863 deletions

View File

@ -14,5 +14,9 @@ def create(target, module_name):
my_module.add_module_depend([
'elog'
])
my_module.add_module_define([
"ETK_BUILD_MINIZIP"
])
return my_module

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -18,11 +18,11 @@ namespace etk {
*
* It is important to note that the color choice denpznd on the level of developent.
* For example :
* :** Graphic application use:
* ::** Image in 3/4 bytes for rgb(a)
* ::** Color description in char : '#F6780FFF' or the equivalent number:0xF6780FFF
* :** middleware will mainely use a the 4 separate value with 1 byte for each.
* :** graphic interface (openGL) store image in 1/2/3/4 bytes color and interpolate it in 'n' float. And note that the user color is sored in float.
* - Graphic application use:
* - Image in 3/4 bytes for rgb(a)
* - Color description in char : '#F6780FFF' or the equivalent number:0xF6780FFF
* - middleware will mainely use a the 4 separate value with 1 byte for each.
* - graphic interface (openGL) store image in 1/2/3/4 bytes color and interpolate it in 'n' float. And note that the user color is sored in float.
*
* Then with this class we abstract the transformation format and set an easy same way to use the color independing of the developpement level.
*
@ -422,7 +422,7 @@ namespace etk {
};
//! @not-in-doc
//! @not_in_doc
template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<uint8_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
std::ostringstream oss;
if (MY_TYPE_SIZE >= 3) {
@ -455,7 +455,7 @@ namespace etk {
}
return _os;
}
//! @not-in-doc
//! @not_in_doc
template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<uint16_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
std::ostringstream oss;
if (MY_TYPE_SIZE >= 4) {
@ -481,7 +481,7 @@ namespace etk {
_os << oss.str() << ")";
return _os;
}
//! @not-in-doc
//! @not_in_doc
template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<uint32_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
std::ostringstream oss;
if (MY_TYPE_SIZE >= 4) {
@ -507,7 +507,7 @@ namespace etk {
_os << oss.str() << ")";
return _os;
}
//! @not-in-doc
//! @not_in_doc
template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<float, MY_TYPE_SIZE>& _obj) { // RGB float & RGBA float
if (MY_TYPE_SIZE >= 4) {
_os << "rgba";
@ -535,7 +535,7 @@ namespace etk {
_os << ")";
return _os;
}
//! @not-in-doc
//! @not_in_doc
template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<double, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
if (MY_TYPE_SIZE >= 4) {
_os << "rgba";
@ -563,7 +563,7 @@ namespace etk {
_os << ")";
return _os;
}
//! @not-in-doc
//! @not_in_doc
template<typename MY_TYPE, int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const std::vector<Color<MY_TYPE, MY_TYPE_SIZE> >& _obj) {
for (size_t iii = 0; iii < _obj.size(); ++iii) {
if (iii != 0) {
@ -727,23 +727,6 @@ namespace etk {
extern const Color<> yellow; //!< ++ [color=yellow] yellow color [/color] ++
extern const Color<> yellowGreen; //!< ++ [color=yellowGreen] yellowGreen color [/color] ++
};
/*
template<> std::string etk::to_string<Color<MY_TYPE, MY_TYPE_SIZE>>(const Color<MY_TYPE, MY_TYPE_SIZE>& _val) {
return _val.getString();
}
template<> std::u32string etk::to_u32string<Color<MY_TYPE, MY_TYPE_SIZE>>(const Color<MY_TYPE, MY_TYPE_SIZE>& _val) {
return etk::to_u32string(_val.getString());
}
template<> bool etk::from_string<Color<MY_TYPE, MY_TYPE_SIZE>>(Color<MY_TYPE, MY_TYPE_SIZE>& _variableRet, const std::u32string& _value) {
_variableRet = Color<MY_TYPE, MY_TYPE_SIZE>(etk::to_string(_value));
return true;
}
template<> bool etk::from_string<Color<MY_TYPE, MY_TYPE_SIZE>>(Color<MY_TYPE, MY_TYPE_SIZE>& _variableRet, const std::string& _value) {
_variableRet = Color<MY_TYPE, MY_TYPE_SIZE>(_value);
return true;
}
*/
};

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -18,7 +18,7 @@ namespace etk {
/**
* @brief internel data of the [class[etk::hash]] class, it contain
* the name and the value of the hash vector.
* @not-in-doc
* @internal
*/
template<class MY_TYPE> class HashData {
public:

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -18,23 +18,15 @@
#include <stdlib.h>
etk::BaseNoise::BaseNoise(ivec2 _size, float _min, float _max) :
m_data(_size.x()*_size.y()),
m_size(_size)
{
m_data(_size.x()*_size.y()),
m_size(_size) {
m_data.resize(_size.x()*_size.y(), 0);
for(int32_t iii=0; iii<m_size.x()*m_size.y(); iii++) {
m_data[iii] = etk::tool::frand(_min, _max);
}
}
etk::BaseNoise::~BaseNoise()
{
}
float etk::BaseNoise::get(int32_t _x, int32_t _y) const
{
float etk::BaseNoise::get(int32_t _x, int32_t _y) const {
// We increment of the size to prevent the <0 result due to the "%" methode ...
_x += m_size.x();
_y += m_size.y();
@ -43,8 +35,7 @@ float etk::BaseNoise::get(int32_t _x, int32_t _y) const
return m_data[_x + _y*m_size.x()];
}
float etk::Noise::smoothNoise(float _x, float _y, const etk::BaseNoise& _noise)
{
float etk::Noise::smoothNoise(float _x, float _y, const etk::BaseNoise& _noise) {
//get fractional part of x and y
float fractX = _x - (int32_t)_x;
float fractY = _y - (int32_t)_y;
@ -68,8 +59,7 @@ float etk::Noise::smoothNoise(float _x, float _y, const etk::BaseNoise& _noise)
}
float etk::Noise::turbulence(float _x, float _y, float _size, const etk::BaseNoise& _noise)
{
float etk::Noise::turbulence(float _x, float _y, float _size, const etk::BaseNoise& _noise) {
float value = 0.0f;
float initialSize = _size;
while(1<=_size) {
@ -80,8 +70,7 @@ float etk::Noise::turbulence(float _x, float _y, float _size, const etk::BaseNoi
// NOTE : with 128 here, we have wood ...
}
float etk::Noise::turbulenceNoSmooth(float _x, float _y, float _size, const etk::BaseNoise& _noise)
{
float etk::Noise::turbulenceNoSmooth(float _x, float _y, float _size, const etk::BaseNoise& _noise) {
float value = 0.0f;
float initialSize = _size;
while(1<=_size) {
@ -93,15 +82,14 @@ float etk::Noise::turbulenceNoSmooth(float _x, float _y, float _size, const etk:
}
etk::Noise::Noise(enum noise _type, ivec2 _size, int32_t _depth) :
m_data(_size.x()*_size.y()),
m_size(_size),
m_type(_type)
{
etk::Noise::Noise(enum etk::noiseType _type, ivec2 _size, int32_t _depth) :
m_data(_size.x()*_size.y()),
m_size(_size),
m_type(_type) {
m_data.resize(_size.x()*_size.y(), 0);
switch(m_type) {
default:
case etk::Noise::NOISE_BASE:
case etk::noiseType_base:
{
etk::BaseNoise myNoise(ivec2(m_size.x()/_depth,m_size.y()/_depth),0.0f,1.0f);
for(int32_t iii=0; iii<m_size.y(); iii++) {
@ -111,7 +99,7 @@ etk::Noise::Noise(enum noise _type, ivec2 _size, int32_t _depth) :
}
}
break;
case etk::Noise::NOISE_SMOOTH:
case etk::noiseType_smooth:
{
etk::BaseNoise myNoise(ivec2(m_size.x()/_depth,m_size.y()/_depth),0.0f,1.0f);
for(int32_t iii=0; iii<m_size.y(); iii++) {
@ -121,7 +109,7 @@ etk::Noise::Noise(enum noise _type, ivec2 _size, int32_t _depth) :
}
}
break;
case etk::Noise::NOISE_TURBULENCE:
case etk::noiseType_turbulence:
{
etk::BaseNoise myNoise(ivec2(m_size.x()/_depth,m_size.y()/_depth),0.0f,1.0f);
for(int32_t iii=0; iii<m_size.y(); iii++) {
@ -131,7 +119,7 @@ etk::Noise::Noise(enum noise _type, ivec2 _size, int32_t _depth) :
}
}
break;
case etk::Noise::NOISE_TURBULENCE_NO_SMOOTH:
case etk::noiseType_turbulence_no_smooth:
{
etk::BaseNoise myNoise(ivec2(m_size.x()/_depth,m_size.y()/_depth),0.0f,1.0f);
for(int32_t iii=0; iii<m_size.y(); iii++) {
@ -141,24 +129,19 @@ etk::Noise::Noise(enum noise _type, ivec2 _size, int32_t _depth) :
}
}
break;
case etk::Noise::NOISE_CLOUD:
case etk::noiseType_cloud:
break;
case etk::Noise::NOISE_MARBLE:
case etk::noiseType_marble:
break;
case etk::Noise::NOISE_WOOD:
case etk::noiseType_wood:
break;
}
}
etk::Noise::~Noise()
{
}
float etk::Noise::get(int32_t _x, int32_t _y) const
{
// We increment of the size to prevent the <0 result due to the "%" methode ...

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -13,8 +13,11 @@
#include <etk/math/Vector2D.h>
namespace etk {
class BaseNoise
{
/**
* @brief BaseNoise Noise basic data.
* @todo Validate it, this is a !!! PROTOTYPE !!!
*/
class BaseNoise {
private:
std::vector<float> m_data;
ivec2 m_size;
@ -23,27 +26,67 @@ namespace etk {
~BaseNoise();
float get(int32_t _x, int32_t _y) const;
};
/**
* @brief List of noise type supported
*/
enum noiseType {
noiseType_base, //!< basic random noise
noiseType_smooth, //!< Noise smoothed
noiseType_turbulence, //!< Noise in turbulence mode
noiseType_turbulence_no_smooth, //!< Noise Turbulence with no smooth apply
noiseType_cloud, //!< Noise like a cloud
noiseType_marble, //!< Noise like marble
noiseType_wood //!< Noise like wood
};
/**
* @brief Noise basic interface.
* @todo Validate it, this is a !!! PROTOTYPE !!!
*/
class Noise {
public:
enum noise {
NOISE_BASE,
NOISE_SMOOTH,
NOISE_TURBULENCE,
NOISE_TURBULENCE_NO_SMOOTH,
NOISE_CLOUD,
NOISE_MARBLE,
NOISE_WOOD
};
private:
std::vector<float> m_data;
ivec2 m_size;
enum noise m_type;
std::vector<float> m_data; //!< Internal data generated
ivec2 m_size; //!< Size of the noise
enum noiseType m_type; //!< Type of the noise
/**
* @brief Calculate the Smooth noise at a specific position
* @param[in] _x X position
* @param[in] _y Y position
* @param[in] _noise Type of noise
* @return Value calculated
*/
float smoothNoise(float _x, float _y, const etk::BaseNoise& _noise);
/**
* @brief Calculate the Tubulence noise at a specific position
* @param[in] _x X position
* @param[in] _y Y position
* @param[in] _size Turbulence ratio value
* @param[in] _noise Type of noise
* @return Value calculated
*/
float turbulence(float _x, float _y, float _size, const etk::BaseNoise& _noise);
/**
* @brief Calculate the Tubulence Not Smooth noise at a specific position
* @param[in] _x X position
* @param[in] _y Y position
* @param[in] _size Turbulence ratio value
* @param[in] _noise Type of noise
* @return Value calculated
*/
float turbulenceNoSmooth(float _x, float _y, float _size, const etk::BaseNoise& _noise);
public:
Noise(enum noise _type, ivec2 _size, int32_t _depth);
~Noise();
/**
* @brief Contructor of a noise specific
* @param[in] _type Type of noise
* @param[in] _size Size of the image output
* @param[in] _depth Depth calculation
*/
Noise(enum noiseType _type, ivec2 _size, int32_t _depth);
/**
* @brief Get value at a specific position
* @param[in] _x X position
* @param[in] _y Y position
* @return Value calculated at this position
*/
float get(int32_t _x, int32_t _y) const;
};
}

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -16,50 +16,95 @@
#include <memory>
namespace etk {
/**
* @brief Element of the archive (with associated data)
*/
class ArchiveContent {
private:
int32_t m_link; //!< number of element open on this file
public:
/**
* @brief Increment the number of user of this resource (permit to keep data alive)
*/
void increaseRef() {
m_link++;
};
}
/**
* @brief Release reference on this data
*/
void decreaseRef() {
m_link--;
};
}
/**
* @brief Get the number of user link with this reference
* @return Count of user connected
*/
int32_t getNumberOfRef() const {
return m_link;
};
}
private:
int32_t m_theoricSize; //!< number of element open on this file
int32_t m_theoricSize; //!< Size set by the zip file (theoric ==> the data has not been read)
public:
/**
* @brief Get the size of the element (size set by Zip file (not read))
* @return the size in Byte of the file
*/
int32_t getTheoricSize() const {
return m_theoricSize;
};
}
private:
std::vector<char> m_data;
std::vector<char> m_data; //!< Data read from the zip file (if m_data.size() != m_theoricSize the data is not read)
public:
/**
* @brief Basic constructor of an element
* @param[in] _basicSize Size of the zip element
*/
ArchiveContent(int32_t _basicSize=0) :
m_link(-1),
m_theoricSize(_basicSize) { };
m_theoricSize(_basicSize) {
}
/**
* @brief Get the size of the Data loaded
* @return number of Byte loaded.
*/
int32_t size() const {
return m_data.size();
};
}
/**
* @brief Get the pointer on the data read from the zip file
* @return void pointer on the data.
*/
void* data() const {
return (void*)&m_data[0];
};
}
/**
* @brief Get the Data Vector on the file.
* @return Vector on the data.
*/
std::vector<char>& getDataVector() {
return m_data;
};
}
};
/**
* @brief Access on a zip data file
*/
class Archive {
private:
mutable std::mutex m_mutex;
mutable std::mutex m_mutex; //!< access mutex (mini-zip does not support multiple access)
public:
/**
* @brief Contructor of the archive element
* @param[in] _fileName Zip file name (or .apk for android)
*/
Archive(const std::string& _fileName) :
m_fileName(_fileName) {
};
virtual ~Archive() { };
/**
* @brief Generic Destructor of the archive element
*/
virtual ~Archive() = default;
protected:
std::string m_fileName; //!< File name when it came from an file
public:
@ -71,7 +116,7 @@ namespace etk {
return m_fileName;
};
protected:
std::map<std::string, ArchiveContent> m_content;
std::map<std::string, ArchiveContent> m_content; //!< list of element of the zip file
public:
/**
* @brief Get the number of elements
@ -121,9 +166,9 @@ namespace etk {
protected:
/**
* @brief Request the load in memory of the concerned file.
* @param[in] _id Id of the file to load.
* @param[in] _it Iterator on the element.
*/
virtual void loadFile(const std::map<std::string, ArchiveContent>::iterator& it) { };
virtual void loadFile(const std::map<std::string, ArchiveContent>::iterator& _it) { };
public:
/**
* @brief Load an Achive with a specific name.
@ -137,13 +182,6 @@ namespace etk {
* @return A pointer an the specified archive, the user might delete it.
*/
static Archive* loadPackage(const std::string& _fileName);
/**
* @brief Create an Achive with a specific name.
* @param[in] _fileName File name of the specific archive.
* @return A pointer an the specified archive. it is empty due to the fact of create a new archive file.
*/
//Archive* create(const std::u32string& _fileName);
};
}
#endif

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -13,16 +13,30 @@
#include <minizip/unzip.h>
}
namespace etk {
/**
* @brief Zip file acces are set in a archive namespace
*/
namespace archive {
/**
* @brief Zip acces interface (wrapper)
*/
class Zip : public etk::Archive {
private:
unzFile m_ctx; //!< mini zip context
unz_global_info m_info; //!< global information of the Zip
public:
/**
* @brief constructor of a zip file access
* @param[in] _fileName File to parse (.zip / .apk)
* @param[in] _offset Offset in the file where to start the parsing of the "zip"
*/
Zip(const std::string& _fileName, uint64_t _offset = 0LL);
/**
* @brief basic destructor
*/
virtual ~Zip();
protected: // herited functions :
virtual void loadFile(const std::map<std::string, ArchiveContent>::iterator& it);
protected:
void loadFile(const std::map<std::string, ArchiveContent>::iterator& _it) override;
};
}
}

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -21,7 +21,6 @@ void etk::init(int _argc, const char** _argv) {
std::string data = _argv[iii];
if ( data == "-h"
|| data == "--help") {
elog::setLevel(elog::logLevelInfo);
TK_PRINT("etk - help : ");
TK_PRINT(" " << _argv[0] << " [options]");
/*

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -8,7 +8,9 @@
#pragma once
#include <string>
/**
* @brief basic namespace of the etk library. (it might contain all the etk fuctions/class/structures without macro)
*/
namespace etk {
/**
* @brief Initialize etk

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -125,6 +125,7 @@ namespace etk {
Matrix2 mat2Scale(float _scale);
Matrix2 mat2Translate(const vec2& _translate);
Matrix2 mat2Skew(const vec2& _skew);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const etk::Matrix2& _obj);
}
// simplify using of matrix ...

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -125,9 +125,7 @@ namespace etk {
Matrix4 matLookAt(const vec3& _eye,
const vec3& _target,
const vec3& _up);
/**
* @brief Debug operator To display the curent element in a Human redeable information
*/
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const etk::Matrix4& _obj);
};
@ -139,9 +137,7 @@ typedef etk::Matrix4 mat4;
#include <vectormath/scalar/vectormath_aos.h>
// To siplify the writing of the code ==> this permit to have the same name with the glsl language...
typedef Vectormath::Aos::Matrix4 mat4;
/**
* @brief Debug operator To display the curent element in a Human redeable information
*/
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const mat4& _obj);
// TODO : Remove this ???

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -14,147 +14,137 @@
#include <vector>
namespace etk {
/**
* @brief Plane equation template: define a plane equation
* @todo Validate it, this is a !!! PROTOTYPE !!!
*/
template <typename T> class Plane {
public :
//member variables
private:
etk::Vector3D<T> m_normal; //!< X.N+intercept=0
T m_intercept;
T m_intercept; //!< interception value
public:
/*****************************************************
* Constructor
*****************************************************/
/**
* @brief Constructor of a Plane
*/
Plane() :
m_normal(0, 0, 0),
m_intercept(0) {
}
/**
* @brief Constructor of a Plane
* @param[in] _normal Normal of the plane
* @param[in] _intercept Interception value of the plane
*/
Plane(etk::Vector3D<T> _normal, T _intercept=0) :
m_normal(_normal),
m_intercept(_intercept) {
}
Plane(const Plane& obj) :
m_normal(obj.m_normal),
m_intercept(obj.m_intercept) {
/**
* @brief Copy constructor of a Plane
* @param[in] _obj Plane object to copy
*/
Plane(const Plane& _obj) :
m_normal(_obj.m_normal),
m_intercept(_obj.m_intercept) {
}
/*****************************************************
* Destructor
*****************************************************/
~Plane() {
};
/**
* @brief
* @param[in,out]
* @return
* @brief Set the normal of the plane
* @param[in] _obj Vector of the normal
*/
void setNormal(const etk::Vector3D<T>& _obj) {
m_normal = _obj;
};
}
/**
* @brief
* @param[in,out]
* @return
* @brief Set interception value of the plane
* @param[in] _intercept Value of the intercept
*/
void setIntercept(float _intercept) {
m_intercept=_intercept;
};
}
/**
* @brief
* @param[in,out]
* @return
* @brief Set the plane with 3 points in the space
* @param[in] _p0 First point
* @param[in] _p1 Second point
* @param[in] _p2 Thrid point
*/
void setFromPoints(const etk::Vector3D<T>& p0,
const etk::Vector3D<T>& p1,
const etk::Vector3D<T>& p2) {
m_normal = (_p1 - _p0).crossProduct(_p2 - _p0);
void setFromPoints(const etk::Vector3D<T>& _p0,
const etk::Vector3D<T>& _p1,
const etk::Vector3D<T>& _p2) {
m_normal = (_p1 - _p0).cross(_p2 - _p0);
m_normal.normalize();
calculateIntercept(_p0);
};
}
/**
* @brief
* @param[in,out]
* @return
* @brief Calculate interception value with a point in the plane
* @param[in] _pointOnPlane Point in the plane
*/
void calculateIntercept(const etk::Vector3D<T>& _pointOnPlane) {
m_intercept=-m_normal.dotProduct(_pointOnPlane);
m_intercept=-m_normal.dot(_pointOnPlane);
}
/**
* @brief
* @param[in,out]
* @return
* @brief Normalize tha plane properties
*/
void normalize() {
float normalLength=m_normal.getLength();
m_normal/=normalLength;
m_intercept/=normalLength;
};
float normalLength = m_normal.getLength();
if (normalLength == 0) {
return;
}
m_normal /= normalLength;
m_intercept /= normalLength;
}
/**
* @brief
* @param[in,out]
* @return
* @brief Get the normal of the plane
* @return Vector of the normal
*/
etk::Vector3D<T> getNormal() {
const etk::Vector3D<T>& getNormal() const {
return m_normal;
};
}
/**
* @brief
* @param[in,out]
* @return
* @brief Get intercept Value of the plane
* @return The Intercept value
*/
float getIntercept() {
T getIntercept() const {
return m_intercept;
}
//find point of intersection of 3 planes
/**
* @brief
* @param[in,out]
* @return
* @brief Get the intersection between 3 planes
* @param[in] _p2 Second plane
* @param[in] _p3 Third plane
* @return vec3(0,0,0) No Intersection find, else when find
*/
bool intersect3(const Plane<T>& _p2,
const Plane<T>& _p3,
etk::Vector3D<T>& _result) {
float denominator = m_normal.dotProduct((_p2.m_normal).crossProduct(_p3.m_normal));
etk::Vector3D<T> intersect3(const Plane<T>& _p2,
const Plane<T>& _p3) {
float denominator = m_normal.dot((_p2.m_normal).cross(_p3.m_normal));
//scalar triple product of normals
if(denominator==0.0f) {
//no intersection
return false;
return etk::Vector3D<T>(0,0,0);
}
etk::Vector3D<T> temp1, temp2, temp3;
temp1 = (_p2.m_normal.crossProduct(_p3.m_normal))*m_intercept;
temp2 = (_p3.m_normal.crossProduct(m_normal)) * _p2.m_intercept;
temp3 = (m_normal.crossProduct(_p2.m_normal)) * _p3.m_intercept;
result=(temp1+temp2+temp3)/(-denominator);
return true;
};
temp1 = (_p2.m_normal.cross(_p3.m_normal))*m_intercept;
temp2 = (_p3.m_normal.cross(m_normal)) * _p2.m_intercept;
temp3 = (m_normal.cross(_p2.m_normal)) * _p3.m_intercept;
return (temp1+temp2+temp3) / (-denominator);
}
/**
* @brief
* @param[in,out]
* @return
* @brief Get distance from a point to the plane
* @param[in] _point Point to calculate the distance
* @return distance of the Point
*/
float getDistance(const etk::Vector3D<T>& _point) const {
return _point.x * m_normal.x
+ _point.y * m_normal.y
+ _point.z * m_normal.z
return _point.x() * m_normal.x()
+ _point.y() * m_normal.y()
+ _point.z() * m_normal.z()
+ m_intercept;
};
}
/**
* @brief
* @param[in,out]
* @return
* @brief Create a linear interpolation of the plane with an other
* @param[in] _p2 Second plane
* @param[in] _factor Factor to scale
* @return New plane equation
*/
Plane<T> linearInterpolate(const Plane<T>& _p2, float _factor) {
Plane<T> result;
@ -162,49 +152,29 @@ namespace etk {
result.m_normal.normalize();
result.m_intercept=m_intercept*(1.0f-_factor) + _p2.m_intercept*_factor;
return result;
};
//operators
}
/**
* @brief
* @param[in,out]
* @return
* @brief Equality compare operator with an other object.
* @param[in] _obj Reference on the comparing object
* @return true The Objects are identical
* @return false The Objects are NOT identical
*/
bool operator==(const Plane<T> & _obj) const {
bool operator==(const Plane<T>& _obj) const {
if( m_normal == _obj.m_normal
&& m_intercept == _obj.m_intercept) {
return true;
}
return false;
};
}
/**
* @brief
* @param[in,out]
* @return
* @brief In-Equality compare operator with an other object.
* @param[in] _obj Reference on the comparing object
* @return true The Objects are NOT identical
* @return false The Objects are identical
*/
bool operator!=(const Plane<T>& _obj) const {
return!((*this) == _obj);
}
//unary operators
/**
* @brief
* @param[in,out]
* @return
*/
Plane<T> operator-() const {
return Plane<T>(-m_normal, -m_intercept);
}
/**
* @brief
* @param[in,out]
* @return
*/
Plane<T> operator+() const {
return *this;
}
};
}

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -14,9 +14,12 @@
#include <math.h>
namespace etk {
/**
* @brief Vectorial 2-dimention vector (x/y)
*/
template <typename T> class Vector2D {
public:
T m_floats[2];
T m_floats[2]; //!< all internal values
public:
/* ****************************************************
* Constructor
@ -27,190 +30,288 @@ namespace etk {
m_floats[0] = (T)34673363;
m_floats[1] = (T)34523535;
#endif
};
Vector2D(T _x, T _y) {
m_floats[0] = _x;
m_floats[1] = _y;
};
}
/**
* @brief Constructor from scalars
* @param[in] _xxx X value
* @param[in] _yyy Y value
*/
Vector2D(T _xxx, T _yyy) {
m_floats[0] = _xxx;
m_floats[1] = _yyy;
}
/**
* @brief Constructor with external vector
* @param[in] _obj The vector to add to this one
*/
Vector2D(const Vector2D<double>& _obj) {
m_floats[0] = (T)_obj.x();
m_floats[1] = (T)_obj.y();
};
}
/**
* @brief Constructor with external vector
* @param[in] _obj The vector to add to this one
*/
Vector2D(const Vector2D<float>& _obj) {
m_floats[0] = (T)_obj.x();
m_floats[1] = (T)_obj.y();
};
}
/**
* @brief Constructor with external vector
* @param[in] _obj The vector to add to this one
*/
Vector2D(const Vector2D<int32_t>& _obj) {
m_floats[0] = (T)_obj.x();
m_floats[1] = (T)_obj.y();
};
}
/**
* @brief Constructor with string data
* @param[in] _str Sting containing the value to parse
*/
Vector2D(const std::string& _str);
#if __CPP_VERSION__ >= 2011
Vector2D(const std::u32string& _str);
#endif
~Vector2D() { };
/* ****************************************************
* = assigment
*****************************************************/
/**
* @brief Operator= Asign the current object with an other object
* @param[in] _obj Reference on the external object
* @return Local reference of the vector asigned
*/
const Vector2D<T>& operator= (const Vector2D<T>& _obj ) {
m_floats[0] = _obj.m_floats[0];
m_floats[1] = _obj.m_floats[1];
return *this;
}
/**
* @brief Operator= Asign the current object with a value
* @param[in] _val Value to assign on the object
* @return Local reference of the vector asigned
*/
const Vector2D<T>& operator= (const T _val ) {
m_floats[0] = _val;
m_floats[1] = _val;
return *this;
}
/* ****************************************************
* == operator
*****************************************************/
/**
* @brief Equality compare operator with an other object.
* @param[in] _obj Reference on the comparing object
* @return true The Objects are identical
* @return false The Objects are NOT identical
*/
bool operator== (const Vector2D<T>& _obj) const {
return ( (T)_obj.m_floats[0] == m_floats[0]
&& (T)_obj.m_floats[1] == m_floats[1]);
}
/* ****************************************************
* != operator
*****************************************************/
/**
* @brief In-Equality compare operator with an other object.
* @param[in] _obj Reference on the comparing object
* @return true The Objects are NOT identical
* @return false The Objects are identical
*/
bool operator!= (const Vector2D<T>& _obj) const {
return ( (T)_obj.m_floats[0] != m_floats[0]
|| (T)_obj.m_floats[1] != m_floats[1]);
}
/* ****************************************************
* += operator
*****************************************************/
/**
* @brief Operator+= Addition an other vertor with this one
* @param[in] _obj Reference on the external object
* @return Local reference of the vector additionned
*/
const Vector2D<T>& operator+= (const Vector2D<T>& _obj) {
m_floats[0] += _obj.m_floats[0];
m_floats[1] += _obj.m_floats[1];
return *this;
}
/**
* @brief Operator+= Addition an other vertor with this one
* @param[in] _val Value to addition at x/y
* @return Local reference of the vector additionned
*/
const Vector2D<T>& operator+= (const T _val) {
m_floats[0] += _val;
m_floats[1] += _val;
return *this;
}
/* ****************************************************
* + operator
*****************************************************/
/**
* @brief Operator+ Addition an other vertor with this one
* @param[in] _obj Reference on the external object
* @return New vector containing the value
*/
Vector2D<T> operator+ (const Vector2D<T>& _obj) const {
Vector2D<T> tmpp(m_floats[0],m_floats[1]);
tmpp.m_floats[0] += _obj.m_floats[0];
tmpp.m_floats[1] += _obj.m_floats[1];
return tmpp;
}
/**
* @brief Operator+ Addition an other vertor with this one
* @param[in] _val Value to addition at x/y
* @return New vector containing the value
*/
Vector2D<T> operator+ (const T _val) const {
Vector2D<T> tmpp(m_floats[0],m_floats[1]);
tmpp.m_floats[0] += _val;
tmpp.m_floats[1] += _val;
return tmpp;
}
/* ****************************************************
* -= operator
*****************************************************/
/**
* @brief Operator-= Decrement an other vertor with this one
* @param[in] _obj Reference on the external object
* @return Local reference of the vector decremented
*/
const Vector2D<T>& operator-= (const Vector2D<T>& _obj) {
m_floats[0] -= _obj.m_floats[0];
m_floats[1] -= _obj.m_floats[1];
return *this;
}
/**
* @brief Operator-= Decrement an other vertor with this one
* @param[in] _val Value to addition at x/y
* @return Local reference of the vector decremented
*/
const Vector2D<T>& operator-= (const T _val) {
m_floats[0] -= _val;
m_floats[1] -= _val;
return *this;
}
/* ****************************************************
* - operator
*****************************************************/
/**
* @brief Operator- Decrement an other vertor with this one
* @param[in] _obj Reference on the external object
* @return New vector containing the value
*/
Vector2D<T> operator- (const Vector2D<T>& _obj) const {
Vector2D<T> tmpp(m_floats[0],m_floats[1]);
tmpp.m_floats[0] -= _obj.m_floats[0];
tmpp.m_floats[1] -= _obj.m_floats[1];
return tmpp;
}
/**
* @brief Operator- Decrement an other vertor with this one
* @param[in] _val Value to addition at x/y
* @return New vector containing the value
*/
Vector2D<T> operator- (const T _val) const {
Vector2D<T> tmpp(m_floats[0],m_floats[1]);
tmpp.m_floats[0] -= _val;
tmpp.m_floats[1] -= _val;
return tmpp;
}
/* ****************************************************
* *= operator
*****************************************************/
/**
* @brief Operator*= Multiplication an other vertor with this one
* @param[in] _obj Reference on the external object
* @return Local reference of the vector multiplicated
*/
const Vector2D<T>& operator*= (const Vector2D<T>& _obj) {
m_floats[0] *= _obj.m_floats[0];
m_floats[1] *= _obj.m_floats[1];
return *this;
}
/**
* @brief Operator*= Multiplication an other vertor with this one
* @param[in] _val Value to addition at x/y
* @return Local reference of the vector multiplicated
*/
const Vector2D<T>& operator*= (const T _val) {
m_floats[0] *= _val;
m_floats[1] *= _val;
return *this;
}
/* ****************************************************
* * operator
*****************************************************/
/**
* @brief Operator* Multiplication an other vertor with this one
* @param[in] _obj Reference on the external object
* @return New vector containing the value
*/
Vector2D<T> operator* (const Vector2D<T>& _obj) const {
Vector2D<T> tmpp(m_floats[0],m_floats[1]);
tmpp.m_floats[0] *= _obj.m_floats[0];
tmpp.m_floats[1] *= _obj.m_floats[1];
return tmpp;
}
/**
* @brief Operator* Multiplication an other vertor with this one
* @param[in] _val Value to addition at x/y
* @return New vector containing the value
*/
Vector2D<T> operator* (const T _val) const {
Vector2D<T> tmpp(m_floats[0],m_floats[1]);
tmpp.m_floats[0] *= _val;
tmpp.m_floats[1] *= _val;
return tmpp;
}
/* ****************************************************
* / operator
*****************************************************/
/**
* @brief Operator/= Dividing an other vertor with this one
* @param[in] _obj Reference on the external object
* @return Local reference of the vector divided
*/
Vector2D<T> operator/ (const Vector2D<T>& _obj) const{
Vector2D<T> tmpp(m_floats[0], m_floats[1]);
tmpp.m_floats[0] /= _obj.m_floats[0];
tmpp.m_floats[1] /= _obj.m_floats[1];
return tmpp;
}
/**
* @brief Operator/= Dividing an other vertor with this one
* @param[in] _val Value to addition at x/y
* @return Local reference of the vector divided
*/
Vector2D<T> operator/ (const T _val) const {
Vector2D<T> tmpp(m_floats[0], m_floats[1]);
tmpp.m_floats[0] /= _val;
tmpp.m_floats[1] /= _val;
return tmpp;
}
/* ****************************************************
* / operator
*****************************************************/
/**
* @brief Operator/ Dividing an other vertor with this one
* @param[in] _obj Reference on the external object
* @return New vector containing the value
*/
const Vector2D<T>& operator/= (const Vector2D<T>& _obj) {
m_floats[0] /= _obj.m_floats[0];
m_floats[1] /= _obj.m_floats[1];
return *this;
}
/**
* @brief Operator/ Dividing an other vertor with this one
* @param[in] _val Value to addition at x/y
* @return New vector containing the value
*/
const Vector2D<T>& operator/= (const T _val) {
m_floats[0] /= _val;
m_floats[1] /= _val;
return *this;
}
/* ****************************************************
* ++ operator
*****************************************************/
/**
* @brief Operator++ Pre-incrementation of this vector
* @return Local reference of the vector incremented
*/
Vector2D<T>& operator++() {
++m_floats[0];
++m_floats[1];
return *this;
}
Vector2D<T> operator++(int _unused) {
/**
* @brief Operator++ Post-incrementation of this vector
* @return New vector containing the last value
*/
Vector2D<T> operator++(int) {
Vector2D<T> result = *this;
++(*this);
return result;
}
/* ****************************************************
* -- operator
*****************************************************/
/**
* @brief Operator++ Pre-decrementation of this vector
* @return Local reference of the vector incremented
*/
Vector2D<T>& operator--() {
--m_floats[0];
--m_floats[1];
return *this;
}
Vector2D<T> operator--(int _unused) {
/**
* @brief Operator++ Post-decrementation of this vector
* @return New vector containing the last value
*/
Vector2D<T> operator--(int) {
Vector2D<T> result = *this;
--(*this);
return result;
@ -218,6 +319,7 @@ namespace etk {
/**
* @brief Return the cross product / determinant
* @param _obj The other vector in the cross product
* @return cross product value
*/
T cross(const Vector2D<T>& _obj) const {
return m_floats[0] * _obj.m_floats[1]
@ -226,19 +328,22 @@ namespace etk {
/**
* @brief Return the dot product
* @param _obj The other vector in the dot product
* @return Dot product value
*/
T dot(const Vector2D<T>& _obj) const {
return m_floats[0] * _obj.m_floats[0]
+ m_floats[1] * _obj.m_floats[1];
}
/**
* @brief Return the length of the vector squared
* @brief Get the length of the vector squared
* @return Squared length value.
*/
T length2() const {
return dot(*this);
}
/**
* @brief Return the length of the vector
* @brief Get the length of the vector
* @return Length value
*/
float length() const {
#if __CPP_VERSION__ >= 2011 && !defined(__STDCPP_LLVM__)
@ -250,6 +355,8 @@ namespace etk {
/**
* @brief Return the distance squared between the ends of this and another vector
* This is symantically treating the vector like a point
* @param[in] _obj The other vector to compare distance
* @return the square distance of the 2 points
*/
T distance2(const Vector2D<T>& _obj) const {
return (_obj - *this).length2();
@ -257,37 +364,43 @@ namespace etk {
/**
* @brief Return the distance between the ends of this and another vector
* This is symantically treating the vector like a point
* @param[in] _obj The other vector to compare distance
* @return the distance of the 2 points
*/
float distance(const Vector2D<T>& _obj) const {
return (_obj - *this).length();
}
/**
* @brief Normalize this vector
* x^2 + y^2 + z^2 = 1
* @brief Normalize this vector x^2 + y^2 = 1
* @return Local reference of the vector normalized
*/
Vector2D<T>& normalize() {
*this /= length();
return *this;
}
/**
* @brief Normalize this vector
* x^2 + y^2 + z^2 = 1
* @brief Normalize this vector x^2 + y^2 = 1 (check if not deviding by 0, if it is the case ==> return (1,0))
* @return Local reference of the vector normalized
*/
Vector2D<T>& safeNormalize() {
T tmp = length();
if (tmp != 0) {
*this /= length();
return *this;
}
setValue(1,0);
return *this;
}
/**
* @brief Return a normalized version of this vector
* @return New vector containing the value
*/
Vector2D<T> normalized() const {
return *this / length();
}
/**
* @brief Return a vector will the absolute values of each element
* @return New vector containing the value
*/
Vector2D<T> absolute() const {
return Vector2D<T>( abs(m_floats[0]),
@ -295,63 +408,85 @@ namespace etk {
}
/**
* @brief Return the axis with the smallest value
* Note return values are 0,1,2 for x, y, or z
* @return values are 0,1 for x or y
*/
int32_t minAxis() const {
return m_floats[0] < m_floats[1] ? 0 : 1;
}
/**
* @brief Return the axis with the largest value
* Note return values are 0,1,2 for x, y, or z
* @return values are 0,1 for x or y
*/
int32_t maxAxis() const {
return m_floats[0] < m_floats[1] ? 1 : 0;
}
/**
* @brief Return the axis with the smallest ABSOLUTE value
* @return values 0,1 for x, or z
*/
int32_t furthestAxis() const {
return absolute().minAxis();
}
/**
* @brief Return the axis with the largest ABSOLUTE value
* @return values 0,1 for x or y
*/
int32_t closestAxis() const {
return absolute().maxAxis();
}
/**
* @brief Return the x value
* @brief Get X value
* @return the x value
*/
const T& getX() const {
return m_floats[0];
}
/**
* @brief Return the y value
* @brief Get Y value
* @return the y value
*/
const T& getY() const {
return m_floats[1];
}
/**
* @brief Set the x value
* @param[in] _xxx New value
*/
void setX(T _x) {
m_floats[0] = _x;
void setX(T _xxx) {
m_floats[0] = _xxx;
};
/**
* @brief Set the y value
* @param[in] _yyy New value
*/
void setY(T _y) {
m_floats[1] = _y;
void setY(T _yyy) {
m_floats[1] = _yyy;
};
/**
* @brief Return the x value
* @brief Get X value
* @return the x value
*/
const T& x() const {
return m_floats[0];
}
/**
* @brief Return the y value
* @brief Get Y value
* @return the y value
*/
const T& y() const {
return m_floats[1];
}
/**
* @brief Cast the vector in the type T* requested.
* @return Pointer on the data
*/
operator T *() {
return &m_floats[0];
}
/**
* @brief Cast the vector in the type const T* requested.
* @return Pointer on the const data
*/
operator const T *() const {
return &m_floats[0];
}
@ -371,58 +506,93 @@ namespace etk {
m_floats[0] = std::min(m_floats[0], _other.m_floats[0]);
m_floats[1] = std::min(m_floats[1], _other.m_floats[1]);
}
/**
* @brief Set Value on the vector
* @param[in] _xxx X value.
* @param[in] _yyy Y value.
*/
void setValue(const T& _xxx, const T& _yyy) {
m_floats[0] = _xxx;
m_floats[1] = _yyy;
}
/**
* @brief Set 0 value on all the vector
*/
void setZero() {
setValue(0,0);
}
/**
* @brief Check if the vector is equal to (0,0)
* @return true The value is equal to (0,0)
* @return false The value is NOT equal to (0,0)
*/
bool isZero() const {
return m_floats[0] == 0
&& m_floats[1] == 0;
}
//!< string cast :
/**
* @brief String caster of the object.
* @return the Object cated in string (x.x,y.y)
*/
operator std::string() const;
#if __CPP_VERSION__ >= 2011
/**
* @brief String caster of the object.
* @return the Object cated in string (x.x,y.y)
*/
operator std::u32string() const;
#endif
};
/**
* @brief Debug operator To display the curent element in a Human redeable information
*/
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const etk::Vector2D<int32_t>& _obj);
//! @previous
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const etk::Vector2D<float>& _obj);
//! @previous
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const etk::Vector2D<uint32_t>& _obj);
//! @previous
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const etk::Vector2D<bool>& _obj);
};
// To siplify the writing of the code ==> this permit to have the same name with the glsl language...
using vec2 = etk::Vector2D<float>;
using ivec2 = etk::Vector2D<int32_t>;
using vec2 = etk::Vector2D<float>;//!< wrapper on etk::Vector2D<float> to have the same naming has OpenGL shader
using ivec2 = etk::Vector2D<int32_t>;//!< wrapper on etk::Vector2D<int32_t> to have the same naming has OpenGL shader
// not compatible with glsl ... but it is better to have a same writing
using uivec2 = etk::Vector2D<uint32_t>;
using bvec2 = etk::Vector2D<bool>;
using uivec2 = etk::Vector2D<uint32_t>;//!< wrapper on etk::Vector2D<uint32_t> to have the same naming has OpenGL shader
using bvec2 = etk::Vector2D<bool>; //!< wrapper on etk::Vector2D<bool> to have the same naming has OpenGL shader
/**
* @brief Limit at integer value the input vector: vec3(1.2, -2.9) ==> vec3(1.0, -2.0)
* @param[in] _val input vector to limit
* @return reduced range of vector
*/
inline vec2 vec2ClipInt32(const vec2& _val) {
return vec2((int32_t)_val.x(), (int32_t)_val.y());
}
/**
* @brief Limit at integer value the input vector: vec3(1.2, -2.9) ==> vec3(1.0, -2.0)
* @param[in] _val input vector to limit
* @return reduced range of vector
*/
inline vec2 vec2ClipInt64(const vec2& _val) {
return vec2((int64_t)_val.x(), (int64_t)_val.y());
}
vec2 vec2rotate(const vec2& _val, const vec2& _point, float _angle);
/**
* @brief Rotate the vector at a specific position with a specific angle
* @param[in] _obj Vector to rotate
* @param[in] _point Poit to do the rotation
* @param[in] _angle Angle in radian to rotate the vector
* @return New vector wit totation applyed
*/
vec2 vec2rotate(const vec2& _obj, const vec2& _point, float _angle);
namespace etk {
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<vec2 >& _obj);
//! @previous
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<ivec2 >& _obj);
//! @previous
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<uivec2 >& _obj);
//! @previous
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<bvec2 >& _obj);
}

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -21,13 +21,17 @@
namespace etk {
template <typename T> class Vector3D;
};
//! @brief compatibility with bullet lib
typedef etk::Vector3D<float> btVector3;
#endif
namespace etk {
/**
* @brief Vectorial 3-dimention vector (x/y/z)
*/
template <typename T> class Vector3D {
public:
T m_floats[4];
T m_floats[4]; //!< all internal values
public:
/**
* @brief No initialization constructor (faster ...)
@ -49,134 +53,154 @@ namespace etk {
}
/**
* @brief Constructor from scalars
* @param _x X value
* @param _y Y value
* @param _z Z value
* @param[in] _xxx X value
* @param[in] _yyy Y value
* @param[in] _zzz Z value
*/
Vector3D(const T& _x, const T& _y, const T& _z) {
m_floats[0] = _x;
m_floats[1] = _y;
m_floats[2] = _z;
Vector3D(const T& _xxx, const T& _yyy, const T& _zzz) {
m_floats[0] = _xxx;
m_floats[1] = _yyy;
m_floats[2] = _zzz;
m_floats[3] = 0;
}
/**
* @brief Add a vector to this one
* @param _v The vector to add to this one
* @param[in] _obj The vector to add to this one
* @return Local reference of the vector
*/
Vector3D<T>& operator+=(const Vector3D<T>& _v) {
m_floats[0] += _v.m_floats[0];
m_floats[1] += _v.m_floats[1];
m_floats[2] += _v.m_floats[2];
Vector3D<T>& operator+=(const Vector3D<T>& _obj) {
m_floats[0] += _obj.m_floats[0];
m_floats[1] += _obj.m_floats[1];
m_floats[2] += _obj.m_floats[2];
return *this;
}
//! @previous
Vector3D<T> operator+(const Vector3D<T>& _v) {
return Vector3D<T>(m_floats[0] + _v.m_floats[0],
m_floats[1] + _v.m_floats[1],
m_floats[2] + _v.m_floats[2]);
/**
* @brief Add a vector to this one
* @param[in] _obj The vector to add to this one
* @return New vector containing the value
*/
Vector3D<T> operator+(const Vector3D<T>& _obj) {
return Vector3D<T>(m_floats[0] + _obj.m_floats[0],
m_floats[1] + _obj.m_floats[1],
m_floats[2] + _obj.m_floats[2]);
}
/**
* @brief Subtract a vector from this one
* @param _v The vector to subtract
* @param[in] _obj The vector to subtract
* @return Local reference of the vector
*/
Vector3D<T>& operator-=(const Vector3D<T>& _v) {
m_floats[0] -= _v.m_floats[0];
m_floats[1] -= _v.m_floats[1];
m_floats[2] -= _v.m_floats[2];
Vector3D<T>& operator-=(const Vector3D<T>& _obj) {
m_floats[0] -= _obj.m_floats[0];
m_floats[1] -= _obj.m_floats[1];
m_floats[2] -= _obj.m_floats[2];
return *this;
}
//! @previous
Vector3D<T> operator-(const Vector3D<T>& _v) {
return Vector3D<T>(m_floats[0] - _v.m_floats[0],
m_floats[1] - _v.m_floats[1],
m_floats[2] - _v.m_floats[2]);
/**
* @brief Subtract a vector from this one
* @param[in] _obj The vector to subtract
* @return New vector containing the value
*/
Vector3D<T> operator-(const Vector3D<T>& _obj) {
return Vector3D<T>(m_floats[0] - _obj.m_floats[0],
m_floats[1] - _obj.m_floats[1],
m_floats[2] - _obj.m_floats[2]);
}
/**
* @brief Scale the vector
* @param _s Scale factor
* @param[in] _val Scale factor
* @return Local reference of the vector
*/
Vector3D<T>& operator*=(const T& _s) {
m_floats[0] *= _s;
m_floats[1] *= _s;
m_floats[2] *= _s;
Vector3D<T>& operator*=(const T& _val) {
m_floats[0] *= _val;
m_floats[1] *= _val;
m_floats[2] *= _val;
return *this;
}
//! @previous
Vector3D<T> operator*(const T& _s) {
return Vector3D<T>(m_floats[0] * _s,
m_floats[1] * _s,
m_floats[2] * _s);
/**
* @brief Scale the vector
* @param[in] _val Scale factor
* @return New vector containing the value
*/
Vector3D<T> operator*(const T& _val) {
return Vector3D<T>(m_floats[0] * _val,
m_floats[1] * _val,
m_floats[2] * _val);
}
/**
* @brief Inversely scale the vector
* @param _s Scale factor to divide by
* @param[in] _val Scale factor to divide by
* @return Local reference of the vector
*/
Vector3D<T>& operator/=(const Vector3D<T>& _s) {
if (_s != 0) {
return *this *= btScalar(1.0) / _s;
Vector3D<T>& operator/=(const Vector3D<T>& _val) {
if (_val != 0) {
return *this *= float(1.0) / _val;
}
return *this;
}
//! @previous
Vector3D<T>& operator/=(const T& _s) {
if (_s != 0) {
m_floats[0] /= _s;
m_floats[1] /= _s;
m_floats[2] /= _s;
/**
* @brief Inversely scale the vector
* @param[in] _val Scale factor to divide by
* @return Local reference of the vector
*/
Vector3D<T>& operator/=(const T& _val) {
if (_val != 0) {
m_floats[0] /= _val;
m_floats[1] /= _val;
m_floats[2] /= _val;
return *this;
}
return *this;
}
/**
* @brief Return the dot product
* @param _v The other vector in the dot product
* @param[in] _obj The other vector in the dot product
* @return Dot product value
*/
btScalar dot(const Vector3D<T>& _v) const {
return m_floats[0] * _v.m_floats[0]
+ m_floats[1] * _v.m_floats[1]
+ m_floats[2] * _v.m_floats[2];
float dot(const Vector3D<T>& _obj) const {
return m_floats[0] * _obj.m_floats[0]
+ m_floats[1] * _obj.m_floats[1]
+ m_floats[2] * _obj.m_floats[2];
}
/**
* @brief Return the length of the vector squared
* @brief Get the length of the vector squared
* @return Squared length value.
*/
btScalar length2() const {
float length2() const {
return dot(*this);
}
/**
* @brief Return the length of the vector
* @brief Get the length of the vector
* @return Length value
*/
btScalar length() const {
#if __CPP_VERSION__ >= 2011 && !defined(__STDCPP_LLVM__)
float length() const {
#if __CPP_objERSION__ >= 2011 && !defined(__STDCPP_LLVM__)
return std::sqrt(length2());
#else
return sqrt(length2());
#endif
}
/**
* @brief Return the distance squared between the ends of this and another vector
* This is symantically treating the vector like a point
* @param[in] _obj The other vector to compare distance
* @return the square distance of the 2 points
*/
btScalar distance2(const btVector3& _v) const {
return (_v - *this).length2();
float distance2(const Vector3D<T>& _obj) const {
return (_obj - *this).length2();
}
/**
* @brief Return the distance between the ends of this and another vector
* This is symantically treating the vector like a point
* @param[in] _obj The other vector to compare distance
* @return the distance of the 2 points
*/
btScalar distance(const btVector3& _v) const {
return (_v - *this).length();
float distance(const Vector3D<T>& _obj) const {
return (_obj - *this).length();
}
/**
* @brief Normalize this vector x^2 + y^2 + z^2 = 1 (check if not deviding by 0, if it is the case ==> return (1,0,0))
* @return Local reference of the vector normalized
*/
Vector3D<T>& safeNormalize() {
Vector3D<T> absVec = this->absolute();
int maxIndex = absVec.maxAxis();
@ -187,77 +211,80 @@ namespace etk {
setValue(1,0,0);
return *this;
}
/**
* @brief Normalize this vector
* x^2 + y^2 + z^2 = 1
* @brief Normalize this vector x^2 + y^2 + z^2 = 1
* @return Local reference of the vector normalized
*/
Vector3D<T>& normalize() {
return *this /= length();
}
/**
* @brief Return a normalized version of this vector
* @return New vector containing the value
*/
Vector3D<T> normalized() const {
Vector3D<T> out = *this;
out /= length();
return out;
}
/**
* @brief Return a rotated version of this vector
* @param _wAxis The axis to rotate about
* @param _angle The angle to rotate by
* @param[in] _wAxis The axis to rotate about
* @param[in] _angle The angle to rotate by
* @return New vector containing the value
*/
Vector3D<T> rotate( const Vector3D<T>& _wAxis, const btScalar _angle ) const {
Vector3D<T> rotate( const Vector3D<T>& _wAxis, const float _angle ) const {
Vector3D<T> o = _wAxis * _wAxis.dot( *this );
Vector3D<T> x = *this - o;
Vector3D<T> y;
y = _wAxis.cross( *this );
return ( o + x * cosf(_angle) + y * sinf(_angle) );
}
/**
* @brief Return the angle between this and another vector
* @param _v The other vector
* @brief Calculate the angle between this and another vector
* @param[in] _obj The other vector
* @return Angle in radian
*/
btScalar angle(const Vector3D<T>& _v) const {
btScalar s = sqrtf(length2() * _v.length2());
float angle(const Vector3D<T>& _obj) const {
float s = sqrtf(length2() * _obj.length2());
if (0!=s) {
return acosf(dot(_v) / s);
return acosf(dot(_obj) / s);
}
return 0;
}
/**
* @brief Return a vector will the absolute values of each element
* @return New vector containing the value
*/
Vector3D<T> absolute() const {
return Vector3D<T>( abs(m_floats[0]),
abs(m_floats[1]),
abs(m_floats[2]));
}
/**
* @brief Return the cross product between this and another vector
* @param _v The other vector
* @param[in] _obj The other vector
* @return Vector with the result of the cross product
*/
Vector3D<T> cross(const Vector3D<T>& _v) const {
return Vector3D<T>(m_floats[1] * _v.m_floats[2] - m_floats[2] * _v.m_floats[1],
m_floats[2] * _v.m_floats[0] - m_floats[0] * _v.m_floats[2],
m_floats[0] * _v.m_floats[1] - m_floats[1] * _v.m_floats[0]);
Vector3D<T> cross(const Vector3D<T>& _obj) const {
return Vector3D<T>(m_floats[1] * _obj.m_floats[2] - m_floats[2] * _obj.m_floats[1],
m_floats[2] * _obj.m_floats[0] - m_floats[0] * _obj.m_floats[2],
m_floats[0] * _obj.m_floats[1] - m_floats[1] * _obj.m_floats[0]);
}
T triple(const Vector3D<T>& _v1, const Vector3D<T>& _v2) const {
return m_floats[0] * (_v1.m_floats[1] * _v2.m_floats[2] - _v1.m_floats[2] * _v2.m_floats[1])
+ m_floats[1] * (_v1.m_floats[2] * _v2.m_floats[0] - _v1.m_floats[0] * _v2.m_floats[2])
+ m_floats[2] * (_v1.m_floats[0] * _v2.m_floats[1] - _v1.m_floats[1] * _v2.m_floats[0]);
}
/**
* @brief Return the axis with the smallest value
* Note return values are 0,1,2 for x, y, or z
* @brief Return the triple product between this and another vector and another
* @param[in] _obj1 The other vector 1
* @param[in] _obj2 The other vector 2
* @return Value with the result of the triple product
*/
T triple(const Vector3D<T>& _obj1, const Vector3D<T>& _obj2) const {
return m_floats[0] * (_obj1.m_floats[1] * _obj2.m_floats[2] - _obj1.m_floats[2] * _obj2.m_floats[1])
+ m_floats[1] * (_obj1.m_floats[2] * _obj2.m_floats[0] - _obj1.m_floats[0] * _obj2.m_floats[2])
+ m_floats[2] * (_obj1.m_floats[0] * _obj2.m_floats[1] - _obj1.m_floats[1] * _obj2.m_floats[0]);
}
/**
* @brief Return the axis with the smallest value
* @return values 0,1,2 for x, y, or z
*/
int32_t minAxis() const {
if (m_floats[0] < m_floats[1]) {
@ -265,10 +292,9 @@ namespace etk {
}
return m_floats[1] < m_floats[2] ? 1 : 2;
}
/**
* @brief Return the axis with the largest value
* Note return values are 0,1,2 for x, y, or z
* @return values 0,1,2 for x, y, or z
*/
int32_t maxAxis() const {
if (m_floats[0] < m_floats[1]) {
@ -276,226 +302,278 @@ namespace etk {
}
return m_floats[0] < m_floats[2] ? 2 : 0;
}
/**
* @brief Return the axis with the smallest ABSOLUTE value
* @return values 0,1,2 for x, y, or z
*/
int32_t furthestAxis() const {
return absolute().minAxis();
}
/**
* @brief Return the axis with the largest ABSOLUTE value
* @return values 0,1,2 for x, y, or z
*/
int32_t closestAxis() const {
return absolute().maxAxis();
}
void setInterpolate3(const Vector3D<T>& _v0, const Vector3D<T>& _v1, T _rt) {
btScalar s = 1.0 - _rt;
m_floats[0] = s * _v0.m_floats[0] + _rt * _v1.m_floats[0];
m_floats[1] = s * _v0.m_floats[1] + _rt * _v1.m_floats[1];
m_floats[2] = s * _v0.m_floats[2] + _rt * _v1.m_floats[2];
//don't do the unused w component
/**
* @brief Interpolate the vector with a ration between 2 others
* @param[in] _obj0 First vector
* @param[in] _obj1 Second vector
* @param[in] _ratio Ratio between _obj0 and _obj1
*/
void setInterpolate3(const Vector3D<T>& _obj0, const Vector3D<T>& _obj1, T _ratio) {
float inverse = 1.0 - _ratio;
m_floats[0] = inverse * _obj0.m_floats[0] + _ratio * _obj1.m_floats[0];
m_floats[1] = inverse * _obj0.m_floats[1] + _ratio * _obj1.m_floats[1];
m_floats[2] = inverse * _obj0.m_floats[2] + _ratio * _obj1.m_floats[2];
// m_co[3] = s * v0[3] + rt * v1[3];
}
/**
* @brief Return the linear interpolation between this and another vector
* @param _v The other vector
* @param _t The ration of this to v (t = 0 => return this, t=1 => return other)
* @brief Return the linear interpolation between this and another vector
* @param[in] _obj The other vector
* @param[in] _ratio The ratio of this to _obj (_ratio = 0 => return copy of this, _ratio=1 => return other)
* @return New vector containing the value
*/
Vector3D<T> lerp(const Vector3D<T>& _v, const btScalar& _t) const {
return Vector3D<T>(m_floats[0] + (_v.m_floats[0] - m_floats[0]) * _t,
m_floats[1] + (_v.m_floats[1] - m_floats[1]) * _t,
m_floats[2] + (_v.m_floats[2] - m_floats[2]) * _t);
Vector3D<T> lerp(const Vector3D<T>& _obj, const float& _ratio) const {
return Vector3D<T>(m_floats[0] + (_obj.m_floats[0] - m_floats[0]) * _ratio,
m_floats[1] + (_obj.m_floats[1] - m_floats[1]) * _ratio,
m_floats[2] + (_obj.m_floats[2] - m_floats[2]) * _ratio);
}
/**
* @brief Elementwise multiply this vector by the other
* @param _v The other vector
* @brief Elementwise multiply this vector by the other
* @param _obj The other vector
* @return Local reference of the vector normalized
*/
Vector3D<T>& operator*=(const Vector3D<T>& _v) {
m_floats[0] *= _v.m_floats[0];
m_floats[1] *= _v.m_floats[1];
m_floats[2] *= _v.m_floats[2];
Vector3D<T>& operator*=(const Vector3D<T>& _obj) {
m_floats[0] *= _obj.m_floats[0];
m_floats[1] *= _obj.m_floats[1];
m_floats[2] *= _obj.m_floats[2];
return *this;
}
//! @previous
Vector3D<T> operator*(const Vector3D<T>& _v) {
return Vector3D<T>(m_floats[0] * _v.m_floats[0],
m_floats[1] * _v.m_floats[1],
m_floats[2] * _v.m_floats[2]);
}
/**
* @brief Return the x value
* @brief Elementwise multiply this vector by the other
* @param _obj The other vector
* @return New vector containing the value
*/
Vector3D<T> operator*(const Vector3D<T>& _obj) {
return Vector3D<T>(m_floats[0] * _obj.m_floats[0],
m_floats[1] * _obj.m_floats[1],
m_floats[2] * _obj.m_floats[2]);
}
/**
* @brief Get X value
* @return the x value
*/
const T& getX() const {
return m_floats[0];
}
/**
* @brief Return the y value
* @brief Get Y value
* @return the y value
*/
const T& getY() const {
return m_floats[1];
}
/**
* @brief Return the z value
* @brief Get Z value
* @return the z value
*/
const T& getZ() const {
return m_floats[2];
}
/**
* @brief Set the x value
* @param[in] _x New value
*/
void setX(T _x) {
m_floats[0] = _x;
};
}
/**
* @brief Set the y value
* @param[in] _y New value
*/
void setY(T _y) {
m_floats[1] = _y;
};
}
/**
* @brief Set the z value
* @param[in] _z New value
*/
void setZ(T _z) {
m_floats[2] = _z;
};
}
/**
* @brief Set the w value
*/
void setW(T _w) {
m_floats[3] = _w;
};
/**
* @brief Return the x value
* @brief Get X value
* @return the x value
*/
const T& x() const {
return m_floats[0];
}
/**
* @brief Return the y value
* @brief Get Y value
* @return the y value
*/
const T& y() const {
return m_floats[1];
}
/**
* @brief Return the z value
* @brief Get Z value
* @return the z value
*/
const T& z() const {
return m_floats[2];
}
/**
* @brief Return the w value
* @brief Cast the vector in the type T* requested.
* @return Pointer on the data
*/
const T& w() const {
return m_floats[3];
}
operator T *() {
return &m_floats[0];
}
//! @previous
/**
* @brief Cast the vector in the type const T* requested.
* @return Pointer on the const data
*/
operator const T *() const {
return &m_floats[0];
}
bool operator==(const Vector3D<T>& _other) const {
return ( (m_floats[3] == _other.m_floats[3])
&& (m_floats[2] == _other.m_floats[2])
&& (m_floats[1] == _other.m_floats[1])
&& (m_floats[0] == _other.m_floats[0]));
}
bool operator!=(const Vector3D<T>& _other) const {
return ( (m_floats[3] != _other.m_floats[3])
|| (m_floats[2] != _other.m_floats[2])
|| (m_floats[1] != _other.m_floats[1])
|| (m_floats[0] != _other.m_floats[0]));
}
/**
* @brief Set each element to the max of the current values and the values of another btVector3
* @param _other The other btVector3 to compare with
* @brief Equality compare operator with an other object.
* @param[in] _obj Reference on the comparing object
* @return true The Objects are identical
* @return false The Objects are NOT identical
*/
void setMax(const Vector3D<T>& _other) {
btSetMax(m_floats[0], _other.m_floats[0]);
btSetMax(m_floats[1], _other.m_floats[1]);
btSetMax(m_floats[2], _other.m_floats[2]);
btSetMax(m_floats[3], _other.m_floats[3]);
bool operator==(const Vector3D<T>& _obj) const {
return ( (m_floats[3] == _obj.m_floats[3])
&& (m_floats[2] == _obj.m_floats[2])
&& (m_floats[1] == _obj.m_floats[1])
&& (m_floats[0] == _obj.m_floats[0]));
}
/**
* @brief Set each element to the min of the current values and the values of another btVector3
* @param _other The other btVector3 to compare with
* @brief In-Equality compare operator with an other object.
* @param[in] _obj Reference on the comparing object
* @return true The Objects are NOT identical
* @return false The Objects are identical
*/
void setMin(const Vector3D<T>& _other) {
btSetMin(m_floats[0], _other.m_floats[0]);
btSetMin(m_floats[1], _other.m_floats[1]);
btSetMin(m_floats[2], _other.m_floats[2]);
btSetMin(m_floats[3], _other.m_floats[3]);
bool operator!=(const Vector3D<T>& _obj) const {
return ( (m_floats[3] != _obj.m_floats[3])
|| (m_floats[2] != _obj.m_floats[2])
|| (m_floats[1] != _obj.m_floats[1])
|| (m_floats[0] != _obj.m_floats[0]));
}
void setValue(const T& _x, const T& _y, const T& _z) {
m_floats[0]=_x;
m_floats[1]=_y;
m_floats[2]=_z;
/**
* @brief Set each element to the max of the current values and the values of another Vector3D<T>
* @param _obj The other Vector3D<T> to compare with
*/
void setMax(const Vector3D<T>& _obj) {
btSetMax(m_floats[0], _obj.m_floats[0]);
btSetMax(m_floats[1], _obj.m_floats[1]);
btSetMax(m_floats[2], _obj.m_floats[2]);
btSetMax(m_floats[3], _obj.m_floats[3]);
}
/**
* @brief Set each element to the min of the current values and the values of another Vector3D<T>
* @param _obj The other Vector3D<T> to compare with
*/
void setMin(const Vector3D<T>& _obj) {
btSetMin(m_floats[0], _obj.m_floats[0]);
btSetMin(m_floats[1], _obj.m_floats[1]);
btSetMin(m_floats[2], _obj.m_floats[2]);
btSetMin(m_floats[3], _obj.m_floats[3]);
}
/**
* @brief Set Value on the vector
* @param[in] _xxx X value.
* @param[in] _yyy Y value.
* @param[in] _zzz Z value.
*/
void setValue(const T& _xxx, const T& _yyy, const T& _zzz) {
m_floats[0]=_xxx;
m_floats[1]=_yyy;
m_floats[2]=_zzz;
m_floats[3] = 0;
}
void getSkewSymmetricMatrix(Vector3D<T>* _v0,Vector3D<T>* _v1,Vector3D<T>* _v2) const {
_v0->setValue(0. ,-z() ,y());
_v1->setValue(z() ,0. ,-x());
_v2->setValue(-y() ,x() ,0.);
/**
* @brief Create a skew matrix of the object
* @param[out] _obj0 Vector matric first line
* @param[out] _obj1 Vector matric second line
* @param[out] _obj2 Vector matric third line
*/
void getSkewSymmetricMatrix(Vector3D<T>* _obj0,Vector3D<T>* _obj1,Vector3D<T>* _obj2) const {
_obj0->setValue(0. ,-z() ,y());
_obj1->setValue(z() ,0. ,-x());
_obj2->setValue(-y() ,x() ,0.);
}
/**
* @brief Set 0 value on all the vector
*/
void setZero() {
setValue(0,0,0);
}
/**
* @brief Check if the vector is equal to (0,0,0)
* @return true The value is equal to (0,0,0)
* @return false The value is NOT equal to (0,0,0)
*/
bool isZero() const {
return m_floats[0] == 0 && m_floats[1] == 0 && m_floats[2] == 0;
return m_floats[0] == 0
&& m_floats[1] == 0
&& m_floats[2] == 0;
}
};
/**
* @brief Debug operator To display the curent element in a Human redeable information
*/
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const etk::Vector3D<int32_t>& _obj);
//! @previous
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const etk::Vector3D<uint32_t>& _obj);
//! @previous
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const etk::Vector3D<bool>& _obj);
};
std::ostream& operator <<(std::ostream& _os, const btVector3& _obj);
// To siplify the writing of the code ==> this permit to have the same name with the glsl language...
#ifdef ETK_BUILD_LINEARMATH
typedef btVector3 vec3;
typedef btVector3 vec3; //!< wrapper on etk::Vector3D<float> to have the same naming has OpenGL shader
#else
typedef etk::Vector3D<float> vec3;
typedef etk::Vector3D<float> vec3; //!< wrapper on etk::Vector3D<float> to have the same naming has OpenGL shader
#endif
typedef etk::Vector3D<float> ovec3; // specific for OpenGL ... ==> never change this ...
typedef etk::Vector3D<int32_t> ivec3;
typedef etk::Vector3D<float> ovec3; //!< wrapper on etk::Vector3D<float> to be complient all time with openGL internal mode (instead of vec3)
typedef etk::Vector3D<int32_t> ivec3; //!< wrapper on etk::Vector3D<int32_t> to have the same naming has OpenGL shader
// not compatible with glsl ... but it is better to have a same writing
typedef etk::Vector3D<uint32_t> uivec3;
typedef etk::Vector3D<bool> bvec3;
typedef etk::Vector3D<uint32_t> uivec3; //!< wrapper on etk::Vector3D<uint32_t> to have the same naming has OpenGL shader
typedef etk::Vector3D<bool> bvec3; //!< wrapper on etk::Vector3D<bool> to have the same naming has OpenGL shader
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const vec3& _obj);
#ifdef ETK_BUILD_LINEARMATH
vec3 quaternionToEulerXYZ(const btQuaternion& quat);
#endif
inline vec3 vec3ClipInt32(const vec3& val) {
return vec3((int32_t)val.x(), (int32_t)val.y(), (int32_t)val.z());
/**
* @brief Limit at integer value the input vector: vec3(1.2, 5.6, -2.9) ==> vec3(1.0, 5.0, -2.0)
* @param _val input vector to limit
* @return reduced range of vector
*/
inline vec3 vec3ClipInt32(const vec3& _val) {
return vec3(int32_t(_val.x()), int32_t(_val.y()), int32_t(_val.z()));
}
inline vec3 vec3ClipInt64(const vec3& val) {
return vec3((int64_t)val.x(), (int64_t)val.y(), (int64_t)val.z());
/**
* @brief Limit at integer value the input vector: vec3(1.2, 5.6, -2.9) ==> vec3(1.0, 5.0, -2.0)
* @param _val input vector to limit
* @return reduced range of vector
*/
inline vec3 vec3ClipInt64(const vec3& _val) {
return vec3(int64_t(_val.x()), int64_t(_val.y()), int64_t(_val.z()));
}
namespace etk {
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<vec3>& _obj);
//! @previous
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<ivec3>& _obj);
//! @previous
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<uivec3>& _obj);
//! @previous
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<bvec3>& _obj);
}

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -21,9 +21,12 @@
};
#endif
namespace etk {
/**
* @brief Vectorial 4-dimention vector (x/y/z/w)
*/
template <typename T> class Vector4D {
public:
T m_floats[4];
T m_floats[4]; //!< all internal values
public:
/**
* @brief No initialization constructor (faster ...)
@ -31,121 +34,144 @@ namespace etk {
Vector4D() {
#ifdef DEBUG
// in debug mode we set supid value to prevent forget of the inits ...
m_floats[0] = (T)34673363;
m_floats[1] = (T)34523535;
m_floats[2] = (T)43523424;
m_floats[3] = (T)23452345;
m_floats[0] = T(34673363);
m_floats[1] = T(34523535);
m_floats[2] = T(43523424);
m_floats[3] = T(23452345);
#endif
}
/**
* @brief Constructor from scalars
* @param x X value
* @param y Y value
* @param z Z value
* @brief Constructor from scalars.
* @param _xxx X value
* @param _yyy Y value
* @param _zzz Z value
* @param _www W value
*/
Vector4D(const T& _x, const T& _y, const T& _z, const T& _w) {
m_floats[0] = _x;
m_floats[1] = _y;
m_floats[2] = _z;
m_floats[3] = _w;
Vector4D(const T& _xxx, const T& _yyy, const T& _zzz, const T& _www) {
m_floats[0] = _xxx;
m_floats[1] = _yyy;
m_floats[2] = _zzz;
m_floats[3] = _www;
}
/**
* @brief Add a vector to this one
* @param The vector to add to this one
* @brief Add a vector to this one.
* @param[in] _obj The vector to add to this one
* @return Local reference of the vector
*/
Vector4D<T>& operator+=(const Vector4D<T>& v) {
m_floats[0] += v.m_floats[0];
m_floats[1] += v.m_floats[1];
m_floats[2] += v.m_floats[2];
m_floats[3] += v.m_floats[3];
Vector4D<T>& operator+=(const Vector4D<T>& _obj) {
m_floats[0] += _obj.m_floats[0];
m_floats[1] += _obj.m_floats[1];
m_floats[2] += _obj.m_floats[2];
m_floats[3] += _obj.m_floats[3];
return *this;
}
Vector4D<T> operator+(const Vector4D<T>& v) {
return Vector4D<T>(m_floats[0] + v.m_floats[0],
m_floats[1] + v.m_floats[1],
m_floats[2] + v.m_floats[2],
m_floats[3] + v.m_floats[3]);
/**
* @brief Add a vector to this one.
* @param[in] _obj The vector to add to this one
* @return New vector containing the value
*/
Vector4D<T> operator+(const Vector4D<T>& _obj) {
return Vector4D<T>(m_floats[0] + _obj.m_floats[0],
m_floats[1] + _obj.m_floats[1],
m_floats[2] + _obj.m_floats[2],
m_floats[3] + _obj.m_floats[3]);
}
/**
* @brief Subtract a vector from this one
* @param The vector to subtract
* @param _obj The vector to subtract
* @return Local reference of the vector
*/
Vector4D<T>& operator-=(const Vector4D<T>& v) {
m_floats[0] -= v.m_floats[0];
m_floats[1] -= v.m_floats[1];
m_floats[2] -= v.m_floats[2];
m_floats[3] -= v.m_floats[3];
Vector4D<T>& operator-=(const Vector4D<T>& _obj) {
m_floats[0] -= _obj.m_floats[0];
m_floats[1] -= _obj.m_floats[1];
m_floats[2] -= _obj.m_floats[2];
m_floats[3] -= _obj.m_floats[3];
return *this;
}
Vector4D<T> operator-(const Vector4D<T>& v) {
return Vector4D<T>(m_floats[0] - v.m_floats[0],
m_floats[1] - v.m_floats[1],
m_floats[2] - v.m_floats[2],
m_floats[3] - v.m_floats[3]);
/**
* @brief Subtract a vector from this one
* @param _obj The vector to subtract
* @return New vector containing the value
*/
Vector4D<T> operator-(const Vector4D<T>& _obj) {
return Vector4D<T>(m_floats[0] - _obj.m_floats[0],
m_floats[1] - _obj.m_floats[1],
m_floats[2] - _obj.m_floats[2],
m_floats[3] - _obj.m_floats[3]);
}
/**
* @brief Scale the vector
* @param s Scale factor
* @param[in] _val Scale factor
* @return Local reference of the vector
*/
Vector4D<T>& operator*=(const T& s) {
m_floats[0] *= s;
m_floats[1] *= s;
m_floats[2] *= s;
m_floats[3] *= s;
Vector4D<T>& operator*=(const T& _val) {
m_floats[0] *= _val;
m_floats[1] *= _val;
m_floats[2] *= _val;
m_floats[3] *= _val;
return *this;
}
Vector4D<T> operator*(const T& s) {
return Vector4D<T>(m_floats[0] * s,
m_floats[1] * s,
m_floats[2] * s,
m_floats[3] * s);
}
/**
* @brief Inversely scale the vector
* @param s Scale factor to divide by
* @brief Scale the vector
* @param[in] _val Scale factor
* @return New vector containing the value
*/
Vector4D<T>& operator/=(const Vector4D<T>& s) {
if (0!=s) {
return *this *= 1.0f / s;
}
return *this;
Vector4D<T> operator*(const T& _val) {
return Vector4D<T>(m_floats[0] * _val,
m_floats[1] * _val,
m_floats[2] * _val,
m_floats[3] * _val);
}
Vector4D<T>& operator/=(const T& s) {
if (0!=s) {
m_floats[0]/=s;
m_floats[1]/=s;
m_floats[2]/=s;
m_floats[3]/=s;
/**
* @brief Inversely scale the vector
* @param[in] _val Scale factor to divide by.
* @return Local reference of the vector
*/
Vector4D<T>& operator/=(const T& _val) {
if (_val != 0) {
m_floats[0] /= _val;
m_floats[1] /= _val;
m_floats[2] /= _val;
m_floats[3] /= _val;
return *this;
}
return *this;
}
/**
* @brief Inversely scale the vector
* @param[in] _val Scale factor to divide by.
* @return New vector containing the value
*/
Vector4D<T> operator/(const T& _val) {
if (_val != 0) {
return Vector4D<T>(m_floats[0] / _val,
m_floats[1] / _val,
m_floats[2] / _val,
m_floats[3] / _val);
}
return *this;
}
/**
* @brief Return the dot product
* @param v The other vector in the dot product
* @param _obj The other vector in the dot product
* @return Dot result value
*/
float dot(const Vector4D<T>& v) const {
return m_floats[0] * v.m_floats[0] +
m_floats[1] * v.m_floats[1] +
m_floats[2] * v.m_floats[2] +
m_floats[3] * v.m_floats[3];
float dot(const Vector4D<T>& _obj) const {
return m_floats[0] * _obj.m_floats[0] +
m_floats[1] * _obj.m_floats[1] +
m_floats[2] * _obj.m_floats[2] +
m_floats[3] * _obj.m_floats[3];
}
/**
* @brief Return the length of the vector squared
* @brief Return the squared length of the vector.
* @return Squared length value.
*/
float length2() const {
return dot(*this);
}
/**
* @brief Return the length of the vector
* @return Length value
*/
float length() const {
#ifdef ETK_BUILD_LINEARMATH
@ -158,77 +184,38 @@ namespace etk {
#endif
#endif
}
/**
* @brief Return the distance squared between the ends of this and another vector
* This is symantically treating the vector like a point
* @param[in] _obj The other vector to compare distance
* @return the square distance of the 2 points
*/
float distance2(const Vector4D<T>& v) const {
return (v - *this).length2();
float distance2(const Vector4D<T>& _obj) const {
return (_obj - *this).length2();
}
/**
* @brief Return the distance between the ends of this and another vector
* This is symantically treating the vector like a point
* @param[in] _obj The other vector to compare distance
* @return the distance of the 2 points
*/
float distance(const Vector4D<T>& v) const {
return (v - *this).length();
float distance(const Vector4D<T>& _obj) const {
return (_obj - *this).length();
}
/*
Vector4D<T>& safeNormalize() {
Vector4D<T> absVec = this->absolute();
int maxIndex = absVec.maxAxis();
if (absVec[maxIndex]>0)
{
*this /= absVec[maxIndex];
return *this /= length();
}
setValue(1,0,0);
return *this;
}
*/
/**
* @brief Normalize this vector
* x^2 + y^2 + z^2 = 1
* @brief Normalize this vector x^2 + y^2 + z^2 + w^2 = 1
* @return Local reference of the vector normalized
*/
Vector4D<T>& normalize() {
Vector4D<T>& normalize() {
return *this /= length();
}
/**
* @brief Return a normalized version of this vector
* @return New vector containing the value
*/
Vector4D<T> normalized() const {
return *this / length();
}
/**
* @brief Return a rotated version of this vector
* @param wAxis The axis to rotate about
* @param angle The angle to rotate by
*/
/*
Vector4D<T> rotate( const Vector3D<T>& wAxis, const btScalar angle ) const {
Vector4D<T> o = wAxis * wAxis.dot( *this );
Vector4D<T> _x = *this - o;
Vector4D<T> _y;
_y = wAxis.cross( *this );
return ( o + _x * cosf(angle) + _y * sinf(angle) );
}
*/
/**
* @brief Return the angle between this and another vector
* @param v The other vector
*/
/*
btScalar angle(const Vector3D<T>& v) const {
btScalar s = sqrtf(length2() * v.length2());
if (0!=s) {
return acosf(dot(v) / s);
}
return 0;
}
*/
/**
* @brief Return a vector will the absolute values of each element
*/
@ -238,214 +225,217 @@ namespace etk {
abs(m_floats[2]),
abs(m_floats[3]));
}
/**
* @brief Return the cross product between this and another vector
* @param v The other vector
* @brief Multiply this vector by the other.
* @param _obj The other vector
* @return Local reference of the vector
*/
/*
Vector4D<T> cross(const Vector4D<T>& v) const {
return Vector4D<T>(m_floats[1] * v.m_floats[2] - m_floats[2] * v.m_floats[1],
m_floats[2] * v.m_floats[0] - m_floats[0] * v.m_floats[2],
m_floats[0] * v.m_floats[1] - m_floats[1] * v.m_floats[0]);
}
T triple(const Vector4D<T>& v1, const Vector4D<T>& v2) const {
return m_floats[0] * (v1.m_floats[1] * v2.m_floats[2] - v1.m_floats[2] * v2.m_floats[1])
+ m_floats[1] * (v1.m_floats[2] * v2.m_floats[0] - v1.m_floats[0] * v2.m_floats[2])
+ m_floats[2] * (v1.m_floats[0] * v2.m_floats[1] - v1.m_floats[1] * v2.m_floats[0]);
}
*/
/**
* @brief Return the axis with the smallest value
* Note return values are 0,1,2 for x, y, or z
*/
/*
int32_t minAxis() const {
return m_floats[0] < m_floats[1] ? (m_floats[0] <m_floats[2] ? 0 : 2) : (m_floats[1] <m_floats[2] ? 1 : 2);
}
*/
/**
* @brief Return the axis with the largest value
* Note return values are 0,1,2 for x, y, or z
*/
/*
int32_t maxAxis() const {
return m_floats[0] < m_floats[1] ? (m_floats[1] <m_floats[2] ? 2 : 1) : (m_floats[0] <m_floats[2] ? 2 : 0);
}
int32_t furthestAxis() const {
return absolute().minAxis();
}
int32_t closestAxis() const {
return absolute().maxAxis();
}
void setInterpolate3(const Vector4D<T>& v0, const Vector4D<T>& v1, T rt) {
btScalar s = 1 - rt;
m_floats[0] = s * v0.m_floats[0] + rt * v1.m_floats[0];
m_floats[1] = s * v0.m_floats[1] + rt * v1.m_floats[1];
m_floats[2] = s * v0.m_floats[2] + rt * v1.m_floats[2];
m_floats[3] = s * v0.m_floats[3] + rt * v1.m_floats[3];
//don't do the unused w component
// m_co[3] = s * v0[3] + rt * v1[3];
}
*/
/**
* @brief Return the linear interpolation between this and another vector
* @param v The other vector
* @param t The ration of this to v (t = 0 => return this, t=1 => return other)
*/
/*
Vector3D<T> lerp(const Vector4D<T>& v, const btScalar& t) const {
return Vector3D<T>(m_floats[0] + (v.m_floats[0] - m_floats[0]) * t,
m_floats[1] + (v.m_floats[1] - m_floats[1]) * t,
m_floats[2] + (v.m_floats[2] - m_floats[2]) * t,
m_floats[3] + (v.m_floats[3] - m_floats[3]) * t);
}
*/
/**
* @brief Elementwise multiply this vector by the other
* @param v The other vector
*/
Vector4D<T>& operator*=(const Vector4D<T>& v) {
m_floats[0] *= v.m_floats[0];
m_floats[1] *= v.m_floats[1];
m_floats[2] *= v.m_floats[2];
m_floats[3] *= v.m_floats[3];
Vector4D<T>& operator*=(const Vector4D<T>& _obj) {
m_floats[0] *= _obj.m_floats[0];
m_floats[1] *= _obj.m_floats[1];
m_floats[2] *= _obj.m_floats[2];
m_floats[3] *= _obj.m_floats[3];
return *this;
}
Vector4D<T> operator*(const Vector4D<T>& v) {
return Vector4D<T>(m_floats[0] * v.m_floats[0],
m_floats[1] * v.m_floats[1],
m_floats[2] * v.m_floats[2],
m_floats[3] * v.m_floats[3]);
/**
* @brief Multiply this vector by the other.
* @param _obj The other vector
* @return New vector containing the value
*/
Vector4D<T> operator*(const Vector4D<T>& _obj) {
return Vector4D<T>(m_floats[0] * _obj.m_floats[0],
m_floats[1] * _obj.m_floats[1],
m_floats[2] * _obj.m_floats[2],
m_floats[3] * _obj.m_floats[3]);
}
/**
* @brief Return the x value
* @brief Get X value
* @return the x value
*/
const T& getX() const { return m_floats[0]; }
const T& getX() const {
return m_floats[0];
}
/**
* @brief Return the y value
* @brief Get Y value
* @return the y value
*/
const T& getY() const { return m_floats[1]; }
const T& getY() const {
return m_floats[1];
}
/**
* @brief Return the z value
* @brief Get Z value
* @return the z value
*/
const T& getZ() const { return m_floats[2]; }
const T& getZ() const {
return m_floats[2];
}
/**
* @brief Return the z value
* @brief Get W value
* @return the w value
*/
const T& getW() const { return m_floats[3]; }
const T& getW() const {
return m_floats[3];
}
/**
* @brief Set the x value
* @param[in] _x New value
*/
void setX(T _x) { m_floats[0] = _x;};
void setX(T _x) {
m_floats[0] = _x;
};
/**
* @brief Set the y value
* @param[in] _y New value
*/
void setY(T _y) { m_floats[1] = _y;};
void setY(T _y) {
m_floats[1] = _y;
};
/**
* @brief Set the z value
* @param[in] _z New value
*/
void setZ(T _z) { m_floats[2] = _z;};
void setZ(T _z) {
m_floats[2] = _z;
};
/**
* @brief Set the w value
* @param[in] _w New value
*/
void setW(T _w) { m_floats[3] = _w;};
void setW(T _w) {
m_floats[3] = _w;
};
/**
* @brief Return the x value
* @brief Get X value
* @return the x value
*/
const T& x() const { return m_floats[0]; }
const T& x() const {
return m_floats[0];
}
/**
* @brief Return the y value
* @brief Get Y value
* @return the y value
*/
const T& y() const { return m_floats[1]; }
const T& y() const {
return m_floats[1];
}
/**
* @brief Return the z value
* @brief Get Z value
* @return the z value
*/
const T& z() const { return m_floats[2]; }
const T& z() const {
return m_floats[2];
}
/**
* @brief Return the w value
* @brief Get W value
* @return the w value
*/
const T& w() const { return m_floats[3]; }
operator T *() { return &m_floats[0]; }
operator const T *() const { return &m_floats[0]; }
bool operator==(const Vector4D<T>& other) const {
return ( (m_floats[3]==other.m_floats[3])
&& (m_floats[2]==other.m_floats[2])
&& (m_floats[1]==other.m_floats[1])
&& (m_floats[0]==other.m_floats[0]));
const T& w() const {
return m_floats[3];
}
bool operator!=(const Vector4D<T>& other) const {
return ( (m_floats[3]!=other.m_floats[3])
|| (m_floats[2]!=other.m_floats[2])
|| (m_floats[1]!=other.m_floats[1])
|| (m_floats[0]!=other.m_floats[0]));
}
/**
* @brief Set each element to the max of the current values and the values of another btVector3
* @param other The other btVector3 to compare with
* @brief Cast the vector in the type T* requested.
* @return Pointer on the data
*/
void setMax(const Vector4D<T>& other) {
btSetMax(m_floats[0], other.m_floats[0]);
btSetMax(m_floats[1], other.m_floats[1]);
btSetMax(m_floats[2], other.m_floats[2]);
btSetMax(m_floats[3], other.m_floats[3]);
operator T *() {
return &m_floats[0];
}
/**
* @brief Set each element to the min of the current values and the values of another btVector3
* @param other The other btVector3 to compare with
* @brief Cast the vector in the type const T* requested.
* @return Pointer on the const data
*/
void setMin(const Vector4D<T>& other) {
btSetMin(m_floats[0], other.m_floats[0]);
btSetMin(m_floats[1], other.m_floats[1]);
btSetMin(m_floats[2], other.m_floats[2]);
btSetMin(m_floats[3], other.m_floats[3]);
operator const T *() const {
return &m_floats[0];
}
void setValue(const T& _x, const T& _y, const T& _z, const T& _w) {
m_floats[0]=_x;
m_floats[1]=_y;
m_floats[2]=_z;
m_floats[3]=_w;
/**
* @brief Equality compare operator with an other object.
* @param[in] _obj Reference on the comparing object
* @return true The Objects are identical
* @return false The Objects are NOT identical
*/
bool operator==(const Vector4D<T>& _obj) const {
return ( (m_floats[3] == _obj.m_floats[3])
&& (m_floats[2] == _obj.m_floats[2])
&& (m_floats[1] == _obj.m_floats[1])
&& (m_floats[0] == _obj.m_floats[0]));
}
/*
void getSkewSymmetricMatrix(Vector3D<T>* v0,Vector3D<T>* v1,Vector3D<T>* v2) const {
v0->setValue(0. ,-z() ,y());
v1->setValue(z() ,0. ,-x());
v2->setValue(-y() ,x() ,0.);
/**
* @brief In-Equality compare operator with an other object.
* @param[in] _obj Reference on the comparing object
* @return true The Objects are NOT identical
* @return false The Objects are identical
*/
bool operator!=(const Vector4D<T>& _obj) const {
return ( (m_floats[3] != _obj.m_floats[3])
|| (m_floats[2] != _obj.m_floats[2])
|| (m_floats[1] != _obj.m_floats[1])
|| (m_floats[0] != _obj.m_floats[0]));
}
*/
/**
* @brief Set each element to the max of the current values and the values of another Vector
* @param _obj The other Vector to compare with
*/
void setMax(const Vector4D<T>& _obj) {
btSetMax(m_floats[0], _obj.m_floats[0]);
btSetMax(m_floats[1], _obj.m_floats[1]);
btSetMax(m_floats[2], _obj.m_floats[2]);
btSetMax(m_floats[3], _obj.m_floats[3]);
}
/**
* @brief Set each element to the min of the current values and the values of another Vector
* @param _obj The other Vector to compare with
*/
void setMin(const Vector4D<T>& _obj) {
btSetMin(m_floats[0], _obj.m_floats[0]);
btSetMin(m_floats[1], _obj.m_floats[1]);
btSetMin(m_floats[2], _obj.m_floats[2]);
btSetMin(m_floats[3], _obj.m_floats[3]);
}
/**
* @brief Set Value on the vector
* @param[in] _xxx X value.
* @param[in] _yyy Y value.
* @param[in] _zzz Z value.
* @param[in] _www W value.
*/
void setValue(const T& _xxx, const T& _yyy, const T& _zzz, const T& _www) {
m_floats[0]=_xxx;
m_floats[1]=_yyy;
m_floats[2]=_zzz;
m_floats[3]=_www;
}
/**
* @brief Set 0 value on all the vector
*/
void setZero() {
setValue(0,0,0,0);
}
/**
* @brief Check if the vector is equal to (0,0,0,0)
* @return true The value is equal to (0,0,0,0)
* @return false The value is NOT equal to (0,0,0,0)
*/
bool isZero() const {
return m_floats[0] == 0 && m_floats[1] == 0 && m_floats[2] == 0 && m_floats[3] == 0;
return m_floats[0] == 0
&& m_floats[1] == 0
&& m_floats[2] == 0
&& m_floats[3] == 0;
}
};
/**
* @brief Debug operator To display the curent element in a Human redeable information
*/
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const etk::Vector4D<int32_t>& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const etk::Vector4D<float>& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const etk::Vector4D<uint32_t>& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const etk::Vector4D<bool>& _obj);
}
// To siplify the writing of the code ==> this permit to have the same name with the glsl language...
typedef etk::Vector4D<float> vec4;
typedef etk::Vector4D<int32_t> ivec4;
typedef etk::Vector4D<float> vec4; //!< wrapper on etk::Vector4D<float> to have the same naming has OpenGL shader
typedef etk::Vector4D<int32_t> ivec4; //!< wrapper on etk::Vector4D<int32_t> to have the same naming has OpenGL shader
// not compatible with glsl ... but it is better to have a same writing
typedef etk::Vector4D<uint32_t> uivec4;
typedef etk::Vector4D<bool> bvec4;
typedef etk::Vector4D<uint32_t> uivec4; //!< wrapper on etk::Vector4D<uint32_t> to have the same naming has OpenGL shader
typedef etk::Vector4D<bool> bvec4; //!< wrapper on etk::Vector4D<bool> to have the same naming has OpenGL shader

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -37,9 +37,6 @@ extern "C" {
#include <time.h>
#endif
#undef __class__
#define __class__ "FSNode"
#define TK_DBG_MODE TK_VERBOSE
//#define TK_DBG_MODE TK_DEBUG

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -883,14 +883,14 @@ namespace etk {
* @brief Get all the Path contain in the specidy path:
* @param[in] _path Generic path to parse ...
* @return The list of path found
* @example[start]
* @code
* auto out = etk::FSNodeExplodeMultiplePath("{ewol}DATA:font");
* // out contain: {"DATA:font", "{@ewol}DATA:font"}
* @example[stop]
* @example[start]
* @endcode
* @code
* auto out = etk::FSNodeExplodeMultiplePath("{@ewol}DATA:font");
* // out contain: {"{@ewol}DATA:font"}
* @example[stop]
* @endcode
*/
std::vector<std::string> FSNodeExplodeMultiplePath(const std::string& _path);
};

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -52,6 +52,7 @@ namespace etk {
#endif
std::string getRight() const;
};
//! @not_in_doc
std::ostream& operator <<(std::ostream &_os, const etk::FSNodeRight &_obj);
}

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
@ -63,24 +63,39 @@ namespace utf8 {
#if __CPP_VERSION__ >= 2011
std::u32string convertUnicode(const std::string& _input);
#endif
/**
* @brief Iterator on a simple std::string that contain utf8 value
*/
class iterator {
private:
char32_t m_value; //!< store vlue to prevent multiple calcule of getting the data
std::string* m_data; //!< Pointer on the current Buffer
int64_t m_current; //!< curent Id in the Buffer
public:
/**
* @brief Basic constructor that is not link on a string
*/
iterator():
m_value(u32char::Null),
m_data(nullptr),
m_current(0) {
// nothing to do ...
};
/**
* @brief Basic begin constructor link at the start of the string
* @param[in] _str reference on the string to inspect.
*/
iterator(std::string& _str) :
m_value(u32char::Null),
m_data(&_str),
m_current(0) {
// nothing to do ...
};
/**
* @brief Basic position constructor link at the _pos position of the string
* @param[in] _str reference on the string to inspect.
* @param[in] _pos Iterator position on the string.
*/
iterator(std::string& _str, const std::string::iterator& _pos) :
m_value(u32char::Null),
m_data(&_str),
@ -89,6 +104,11 @@ namespace utf8 {
m_current = std::distance(m_data->begin(), _pos);
}
};
/**
* @brief Basic position constructor link at the _pos position of the string
* @param[in] _str reference on the string to inspect.
* @param[in] _pos Position on the string (in AINSI value).
*/
iterator(std::string& _str, size_t _pos) :
m_value(u32char::Null),
m_data(&_str),
@ -101,6 +121,11 @@ namespace utf8 {
}
}
};
/**
* @brief Basic position constructor link at the _pos position of the string
* @param[in] _str Pointer on the string to inspect.
* @param[in] _pos Iterator position on the string.
*/
iterator(std::string* _str, const std::string::iterator& _pos) :
m_value(u32char::Null),
m_data(_str),
@ -109,6 +134,11 @@ namespace utf8 {
m_current = std::distance(m_data->begin(), _pos);
}
};
/**
* @brief Basic position constructor link at the _pos position of the string
* @param[in] _str Pointer on the string to inspect.
* @param[in] _pos Position on the string (in AINSI value).
*/
iterator(std::string* _str, size_t _pos) :
m_value(u32char::Null),
m_data(_str),
@ -133,7 +163,7 @@ namespace utf8 {
};
/**
* @brief Asignation operator.
* @param[in] _otherIterator The Iterator that might be copy
* @param[in] _obj The Iterator that might be copy
* @return reference on the curent Iterator
*/
iterator& operator=(const iterator & _obj) {
@ -196,6 +226,7 @@ namespace utf8 {
};
/**
* @brief egality iterator
* @param[in] _obj Iterator to compare
* @return true if the iterator is identical pos
*/
bool operator== (const iterator& _obj) const {
@ -207,6 +238,7 @@ namespace utf8 {
};
/**
* @brief egality iterator
* @param[in] _obj Iterator to compare
* @return true if the iterator is identical pos
*/
bool operator!= (const iterator& _obj) const {
@ -218,6 +250,7 @@ namespace utf8 {
};
/**
* @brief <= iterator
* @param[in] _obj Iterator to compare
* @return true if the iterator is identical pos
*/
bool operator<= (const iterator& _obj) const {
@ -231,6 +264,7 @@ namespace utf8 {
};
/**
* @brief >= iterator
* @param[in] _obj Iterator to compare
* @return true if the iterator is identical pos
*/
bool operator>= (const iterator& _obj) const {
@ -244,6 +278,7 @@ namespace utf8 {
};
/**
* @brief < iterator
* @param[in] _obj Iterator to compare
* @return true if the iterator is identical pos
*/
bool operator< (const iterator& _obj) const {
@ -257,6 +292,7 @@ namespace utf8 {
};
/**
* @brief > iterator
* @param[in] _obj Iterator to compare
* @return true if the iterator is identical pos
*/
bool operator> (const iterator& _obj) const {
@ -291,6 +327,7 @@ namespace utf8 {
};
/**
* @brief move the element position
* @param[in] _val Value to add on the Iterator
* @return a new iterator.
*/
iterator operator+ (const int64_t _val) const {
@ -300,6 +337,9 @@ namespace utf8 {
}
return tmpp;
};
/**
* @copydoc utf8::iterator::operator+ (const int64_t)
*/
iterator operator+ (const int32_t _val) const {
iterator tmpp(*this);
for (int64_t iii=0; iii<_val; ++iii) {
@ -307,6 +347,9 @@ namespace utf8 {
}
return tmpp;
};
/**
* @copydoc utf8::iterator::operator+ (const int64_t)
*/
iterator operator+ (const size_t _val) const {
iterator tmpp(*this);
for (int64_t iii=0; iii<(int64_t)_val; ++iii) {
@ -316,6 +359,7 @@ namespace utf8 {
};
/**
* @brief move the element position
* @param[in] _val Value to remove on the Iterator
* @return a new iterator.
*/
iterator operator- (const int64_t _val) const {
@ -325,6 +369,9 @@ namespace utf8 {
}
return tmpp;
};
/**
* @copydoc utf8::iterator::operator- (const int64_t)
*/
iterator operator- (const int32_t _val) const {
iterator tmpp(*this);
for (int64_t iii=0; iii<_val; ++iii) {
@ -332,6 +379,9 @@ namespace utf8 {
}
return tmpp;
};
/**
* @copydoc utf8::iterator::operator- (const int64_t)
*/
iterator operator- (const size_t _val) const {
iterator tmpp(*this);
for (int64_t iii=0; iii<(int64_t)_val; ++iii) {
@ -539,24 +589,39 @@ namespace std {
};
namespace std {
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::string& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<std::string>& _obj);
#if __CPP_VERSION__ >= 2011
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::u32string& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<std::u32string>& _obj);
#endif
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<float>& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<double>& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<int64_t>& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<uint64_t>& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<int32_t>& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<uint32_t>& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<int16_t>& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<uint16_t>& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<int8_t>& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::vector<uint8_t>& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::chrono::system_clock::time_point& _obj);
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::chrono::steady_clock::time_point& _obj);
};

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved

View File

@ -1,4 +1,4 @@
/**
/** @file
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved