Commit 1259ed2c authored by Stefan Philips's avatar Stefan Philips

[ADD] Constructor for WValue with WVector_2 parameter

[ADD] Add toWVector function to WValue
parent cd953d97
......@@ -31,6 +31,7 @@
#include "../WAssert.h"
#include "../WStringUtils.h"
#include "WVector3D.h"
/**
* Base class for all higher level values like tensors, vectors, matrices and so on.
......@@ -77,6 +78,19 @@ public:
}
}
/**
* Create a WValue from the given WVector_2.
* \param newValues The WVector_2 with the values..
*/
explicit WValue( const WVector_2& newValues )
: m_components( static_cast< std::size_t >( newValues.size() ) )
{
for ( std::size_t i = 0; i < m_components.size(); ++i )
{
m_components[ i ] = static_cast< T >( newValues( i ) );
}
}
/**
* Get number of components the value consists of.
*/
......@@ -320,6 +334,19 @@ public:
m_components.resize( size );
}
/**
* Returns this WValue as WVector_2.
*/
WVector_2 toWVector()
{
WVector_2 result ( m_components.size() );
for ( size_t i = 0; i < m_components.size(); ++i )
{
result( i ) = static_cast<double>( m_components[ i ] );
}
return result;
}
protected:
private:
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment