当前位置: 首页>>代码示例>>C++>>正文


C++ kvs::Vec3类代码示例

本文整理汇总了C++中kvs::Vec3的典型用法代码示例。如果您正苦于以下问题:C++ Vec3类的具体用法?C++ Vec3怎么用?C++ Vec3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Vec3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

/*===========================================================================*/
bool StreamlineBase::integrate_by_runge_kutta_2nd(
    const kvs::Vec3& current_vertex,
    const kvs::Vec3& current_direction,
    kvs::Vec3* next_vertex )
{
    if ( m_enable_boundary_condition )
    {
        if ( !this->check_for_inside_volume( current_vertex ) ) return false;
    }

    const float integration_direction = static_cast<float>( m_integration_direction );
    const kvs::Vec3 k1 = current_direction.normalized() * integration_direction;
    // Interpolate vector from vertex of cell.
    const kvs::Vec3 vertex = current_vertex + 0.5f * m_integration_interval * k1;

    if ( m_enable_boundary_condition )
    {
        if ( !this->check_for_inside_volume( vertex ) ) return false;
    }

    const kvs::Vec3 direction = this->interpolate_vector( vertex, current_direction );
    const kvs::Vec3 k2 = direction.normalized() * integration_direction;
    *next_vertex = vertex + m_integration_interval * k2;

    return true;
}
开发者ID:hofsta,项目名称:KVS,代码行数:27,代码来源:StreamlineBase.cpp

示例2: draw

void TextEngine::draw( const kvs::Vec3& p, const std::string& text, kvs::ScreenBase* screen ) const
{
    GLdouble model[16]; kvs::OpenGL::GetModelViewMatrix( model );
    GLdouble proj[16]; kvs::OpenGL::GetProjectionMatrix( proj );
    GLint view[4]; kvs::OpenGL::GetViewport( view );
    GLdouble winx = 0, winy = 0, winz = 0;
    kvs::OpenGL::Project( p.x(), p.y(), p.z(), model, proj, view, &winx, &winy, &winz );

    kvs::OpenGL::WithPushedAttrib attrib( GL_ALL_ATTRIB_BITS );
    attrib.disable( GL_TEXTURE_1D );
    attrib.disable( GL_TEXTURE_2D );
//    attrib.enable( GL_TEXTURE_2D );
    attrib.disable( GL_TEXTURE_3D );
    attrib.enable( GL_DEPTH_TEST );
    attrib.enable( GL_BLEND );
    {
        kvs::OpenGL::SetBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
        kvs::OpenGL::WithPushedMatrix modelview( GL_MODELVIEW );
        modelview.loadIdentity();
        {
            kvs::OpenGL::WithPushedMatrix projection( GL_PROJECTION );
            projection.loadIdentity();
            {
                const GLint left = view[0];
                const GLint top = view[1];
                const GLint right = view[0] + view[2];
                const GLint bottom = view[1] + view[3];
                kvs::OpenGL::SetOrtho( left, right, bottom, top, 0, 1 );
                kvs::OpenGL::Translate( 0, 0, -winz );
                m_font.draw( kvs::Vec2( winx, top - ( winy - bottom ) ), text );
            }
        }
    }
}
开发者ID:naohisas,项目名称:KVS,代码行数:34,代码来源:TextEngine.cpp

示例3: v01

/*===========================================================================*/
kvs::Real32 TetrahedralCell::volume() const
{
    const kvs::Vec3 v01( BaseClass::coord(1) - BaseClass::coord(0) );
    const kvs::Vec3 v02( BaseClass::coord(2) - BaseClass::coord(0) );
    const kvs::Vec3 v03( BaseClass::coord(3) - BaseClass::coord(0) );

    return kvs::Math::Abs( ( v01.cross( v02 ) ).dot( v03 ) ) * 0.166666f;
}
开发者ID:naohisas,项目名称:KVS,代码行数:9,代码来源:TetrahedralCell.cpp

示例4: p

/*===========================================================================*/
const kvs::Vec3 Quaternion::Rotate(
    const kvs::Vec3& pos,
    const kvs::Quaternion& q )
{
    const Quaternion p( pos.x(), pos.y(), pos.z(), 0.0f );
    const Quaternion rotate_conj = q.conjugated();
    const Quaternion rotate_pos = q * p * rotate_conj;
    return rotate_pos.m_elements.xyz();
}
开发者ID:digirea,项目名称:KVS,代码行数:10,代码来源:Quaternion.cpp

示例5: containsLocalPoint

/*===========================================================================*/
bool TetrahedralCell::containsLocalPoint( const kvs::Vec3& local ) const
{
    if ( local.x() < 0 || 1 < local.x() ) { return false; }
    if ( local.y() < 0 || 1 < local.y() ) { return false; }
    if ( local.z() < 0 || 1 < local.z() ) { return false; }
    if ( local.x() + local.y() + local.z() > 1 ) { return false; }
    return true;
}
开发者ID:naohisas,项目名称:KVS,代码行数:9,代码来源:TetrahedralCell.cpp

示例6: updateDifferentialFunctions

/*==========================================================================*/
void QuadraticTetrahedralCell::updateDifferentialFunctions( const kvs::Vec3& local ) const
{
    KVS_ASSERT( BaseClass::containsLocalPoint( local ) );

    const float p = local.x();
    const float q = local.y();
    const float r = local.z();
    const float w = 1 - p - q - r;

    const size_t nnodes = BaseClass::numberOfCellNodes();
    kvs::Real32* dN = BaseClass::differentialFunctions();
    kvs::Real32* dNdp = dN;
    kvs::Real32* dNdq = dNdp + nnodes;
    kvs::Real32* dNdr = dNdq + nnodes;

    // dNdp
    dNdp[0] = -4 * w + 1;
    dNdp[1] =  4 * p - 1;
    dNdp[2] =  0;
    dNdp[3] =  0;
    dNdp[4] =  4 * (w - p);
    dNdp[5] = -4 * r;
    dNdp[6] = -4 * q;
    dNdp[7] =  4 * r;
    dNdp[8] =  0;
    dNdp[9] =  4 * q;

    // dNdq
    dNdq[0] = -4 * w + 1;
    dNdq[1] =  0;
    dNdq[2] =  0;
    dNdq[3] =  4 * q - 1;
    dNdq[4] = -4 * p;
    dNdq[5] = -4 * r;
    dNdq[6] =  4 * (w - q);
    dNdq[7] =  0;
    dNdq[8] =  4 * r;
    dNdq[9] =  4 * p;

    // dNdr
    dNdr[0] = -4 * w + 1;
    dNdr[1] =  0;
    dNdr[2] =  4 * r - 1;
    dNdr[3] =  0;
    dNdr[4] = -4 * p;
    dNdr[5] =  4 * (w - r);
    dNdr[6] = -4 * q;
    dNdr[7] =  4 * p;
    dNdr[8] =  4 * q;
    dNdr[9] =  0;
}
开发者ID:digirea,项目名称:KVS,代码行数:52,代码来源:QuadraticTetrahedralCell.cpp

示例7: updateInterpolationFunctions

/*==========================================================================*/
void TetrahedralCell::updateInterpolationFunctions( const kvs::Vec3& local ) const
{
    KVS_ASSERT( this->containsLocalPoint( local ) );

    const float p = local.x();
    const float q = local.y();
    const float r = local.z();

    kvs::Real32* N = BaseClass::interpolationFunctions();
    N[0] = p;
    N[1] = q;
    N[2] = r;
    N[3] = 1.0f - p - q - r;
}
开发者ID:naohisas,项目名称:KVS,代码行数:15,代码来源:TetrahedralCell.cpp

示例8: isTerminatedByVectorLength

bool StreamlineBase::isTerminatedByVectorLength( const kvs::Vec3& vector )
{
    if ( m_enable_vector_length_condition )
    {
        return vector.length() < m_vector_length_threshold;
    }

    return false;
}
开发者ID:digirea,项目名称:KVS,代码行数:9,代码来源:StreamlineBase.cpp

示例9: transferFunction

/*===========================================================================*/
const kvs::RGBColor Streamline::calculate_color( const kvs::Vec3& direction )
{
    const kvs::Real64 min_length = BaseClass::volume()->minValue();
    const kvs::Real64 max_length = BaseClass::volume()->maxValue();
    const kvs::Real64 diff = direction.length() - min_length;
    const kvs::Real64 interval = max_length - min_length;
    const kvs::UInt8 level = kvs::UInt8( 255.0 * diff / interval );

    return BaseClass::transferFunction().colorMap()[level];
}
开发者ID:fudy1129,项目名称:kvs,代码行数:11,代码来源:Streamline.cpp

示例10: updateDifferentialFunctions

void GridBase::updateDifferentialFunctions( const kvs::Vec3& local )
{
    const float p = local.x();
    const float q = local.y();
    const float r = local.z();
    const float pq = p * q;
    const float qr = q * r;
    const float rp = r * p;

    const size_t nnodes = m_nnodes;
    kvs::Real32* dN = m_differential_functions;
    kvs::Real32* dNdp = dN;
    kvs::Real32* dNdq = dNdp + nnodes;
    kvs::Real32* dNdr = dNdq + nnodes;

    dNdp[0] =  - 1.0f + q +r - qr;
    dNdp[1] =  1.0f - q - r + qr;
    dNdp[2] =  q - qr;
    dNdp[3] =  - q + qr;
    dNdp[4] =  - r + qr;
    dNdp[5] =  r - qr;
    dNdp[6] =  qr;
    dNdp[7] =  - qr;

    dNdq[0] =  - 1.0f + p + r - rp;
    dNdq[1] =  - p + rp;
    dNdq[2] =  p - rp;
    dNdq[3] =  1.0f - p - r + rp;
    dNdq[4] =  - r + rp;
    dNdq[5] =  - rp;
    dNdq[6] =  rp;
    dNdq[7] =  r - rp;

    dNdr[0] =  - 1.0f + q + p - pq;
    dNdr[1] =  - p + pq;
    dNdr[2] =  - pq;
    dNdr[3] =  - q + pq;
    dNdr[4] =  1.0f - q - p + pq;
    dNdr[5] =  p - pq;
    dNdr[6] =  pq;
    dNdr[7] =  q - pq;
}
开发者ID:digirea,项目名称:KVS,代码行数:42,代码来源:GridBase.cpp

示例11: updateInterpolationFunctions

/*==========================================================================*/
void QuadraticTetrahedralCell::updateInterpolationFunctions( const kvs::Vec3& local ) const
{
    KVS_ASSERT( BaseClass::containsLocalPoint( local ) );

    const float p = local.x();
    const float q = local.y();
    const float r = local.z();
    const float w = 1 - p - q - r;

    kvs::Real32* N = BaseClass::interpolationFunctions();
    N[0] = w * (2 * w - 1); // (0, 0, 0)
    N[1] = p * (2 * p - 1); // (1, 0, 0)
    N[2] = r * (2 * r - 1); // (0, 0, 1)
    N[3] = q * (2 * q - 1); // (0, 1, 0)
    N[4] = 4 * p * w; // (1/2,   0,   0)
    N[5] = 4 * r * w; // (  0,   0, 1/2)
    N[6] = 4 * q * w; // (  0, 1/2,   0)
    N[7] = 4 * r * p; // (1/2,   0, 1/2)
    N[8] = 4 * q * r; // (  0, 1/2, 1/2)
    N[9] = 4 * p * q; // (1/2, 1/2,   0)
}
开发者ID:digirea,项目名称:KVS,代码行数:22,代码来源:QuadraticTetrahedralCell.cpp

示例12: updateInterpolationFunctions

void GridBase::updateInterpolationFunctions( const kvs::Vec3& local )
{
    const float p = local.x();
    const float q = local.y();
    const float r = local.z();

    const float pq = p * q;
    const float qr = q * r;
    const float rp = r * p;
    const float pqr = pq * r;

    kvs::Real32* N = m_interpolation_functions;
    N[0] = 1.0f - p - q - r + pq + qr + rp - pqr;
    N[1] = p - pq - rp + pqr;
    N[2] = pq - pqr;
    N[3] = q - pq - qr + pqr;
    N[4] = r - rp - qr + pqr;
    N[5] = rp - pqr;
    N[6] = pqr;
    N[7] = qr - pqr;
}
开发者ID:digirea,项目名称:KVS,代码行数:21,代码来源:GridBase.cpp

示例13: containsLocalPoint

/*===========================================================================*/
bool CellBase::containsLocalPoint( const kvs::Vec3& local ) const
{
    if ( local.x() < 0 || 1 < local.x() ) { return false; }
    if ( local.y() < 0 || 1 < local.y() ) { return false; }
    if ( local.z() < 0 || 1 < local.z() ) { return false; }
    return true;
}
开发者ID:digirea,项目名称:KVS,代码行数:8,代码来源:CellBase.cpp

示例14: X

kvs::Vec3 PrismCell::globalToLocal( const kvs::Vec3 point )
{
    const kvs::Vec3 X( point );

    const float TinyValue = static_cast<float>( 1.e-6 );
    const size_t MaxLoop = 100;
    kvs::Vec3 x0( 0.3f, 0.3f, 0.5f );
    for ( size_t i = 0; i < MaxLoop; i++ )
    {
        this->setLocalPoint( x0 );
        const kvs::Vec3 X0( this->localToGlobal( x0 ) );
        const kvs::Vec3 dX( X - X0 );

        const kvs::Mat3 J( this->JacobiMatrix() );
        const kvs::Vec3 dx = J.transposed().inverted() * dX;
        if ( dx.length() < TinyValue ) break; // Converged.

        x0 += dx;
    }

    return x0;
}
开发者ID:alex159s,项目名称:heatSphereUI,代码行数:22,代码来源:PrismCell.cpp

示例15: X

/*===========================================================================*/
const kvs::Vec3 CellBase::globalToLocal( const kvs::Vec3& global ) const
{
    const kvs::Vec3 X( global );

    // Calculate the coordinate of 'global' in the local coordinate
    // by using Newton-Raphson method.
    const float TinyValue = static_cast<float>( 1.e-6 );
    const size_t MaxLoop = 100;
    kvs::Vec3 x0( 0.25f, 0.25f, 0.25f ); // Initial point in local coordinate.
    for ( size_t i = 0; i < MaxLoop; i++ )
    {
        const kvs::Vec3 X0( this->localToGlobal( x0 ) );
        const kvs::Vec3 dX( X - X0 );

        const kvs::Mat3 J( this->JacobiMatrix() );
        const kvs::Vec3 dx = J.transposed().inverted() * dX;
        if ( dx.length() < TinyValue ) break; // Converged.

        x0 += dx;
    }

    return x0;
}
开发者ID:digirea,项目名称:KVS,代码行数:24,代码来源:CellBase.cpp


注:本文中的kvs::Vec3类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。