• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: RotationQuaternion

/*===========================================================================*/
const Quaternion Quaternion::RotationQuaternion(
    kvs::Vec3 v0,
    kvs::Vec3 v1 )
{
    Quaternion q;

    v0.normalize();
    v1.normalize();

    kvs::Vec3 c = v0.cross( v1 );
    float d = v0.x() * v1.x() + v0.y() * v1.y() + v0.z() * v1.z();
    double s = std::sqrt( double( ( 1 + d ) * 2.0 ) );

    q.x() = float( c.x() / s );
    q.y() = float( c.y() / s );
    q.z() = float( c.z() / s );
    q.w() = float( s / 2.0 );

    return q;
}
开发者ID:digirea,项目名称:KVS,代码行数:21,代码来源:Quaternion.cpp


示例17: integrate_by_euler

/*===========================================================================*/
bool StreamlineBase::integrate_by_euler(
    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;
    *next_vertex = current_vertex + m_integration_interval * k1;

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


示例18: calculate_one_side

/*===========================================================================*/
bool StreamlineBase::calculate_one_side(
    std::vector<kvs::Real32>* coords,
    std::vector<kvs::UInt8>* colors,
    const kvs::Vec3& seed_point,
    const kvs::Vec3& seed_vector )
{
    // Register the seed point.
    kvs::Vec3 current_vertex = seed_point;
    kvs::Vec3 next_vertex = seed_point;

    coords->push_back( seed_point.x() );
    coords->push_back( seed_point.y() );
    coords->push_back( seed_point.z() );

    // Register the vector on the seed point.
    kvs::Vec3 current_vector = seed_vector;
    kvs::Vec3 previous_vector = seed_vector;

    // Set the color of seed point.
    kvs::RGBColor col = this->calculate_color( current_vector );

    colors->push_back( col.r() );
    colors->push_back( col.g() );
    colors->push_back( col.b() );

    size_t integral_times = 0;
    for ( ; ; )
    {
        // Calculate the next vertex.
        if ( !this->calculate_next_vertex(
                 current_vertex,
                 current_vector,
                 &next_vertex ) )
        {
            return true;
        }

        // Check the termination.
        if ( this->check_for_termination(
                 current_vertex,
                 current_vector,
                 integral_times,
                 next_vertex ) )
        {
            return true;
        }

        // Update the vertex and vector.
        current_vertex = next_vertex;
        previous_vector = current_vector;

        coords->push_back( current_vertex.x() );
        coords->push_back( current_vertex.y() );
        coords->push_back( current_vertex.z() );

        // Interpolate vector from vertex of cell.
        current_vector = this->interpolate_vector( current_vertex, previous_vector );

        // Set color of vertex.
        kvs::RGBColor col = this->calculate_color( current_vector );

        colors->push_back( col.r() );
        colors->push_back( col.g() );
        colors->push_back( col.b() );

        integral_times++;
    }
}
开发者ID:hofsta,项目名称:KVS,代码行数:69,代码来源:StreamlineBase.cpp


示例19: v3

/*===========================================================================*/
kvs::Vec3 TetrahedralCell::globalToLocal( const kvs::Vec3& global ) const
{
    const kvs::Vec3 v3( BaseClass::coord(3) );
    const kvs::Vec3 v03( BaseClass::coord(0) - v3 );
    const kvs::Vec3 v13( BaseClass::coord(1) - v3 );
    const kvs::Vec3 v23( BaseClass::coord(2) - v3 );

    const kvs::Mat3 M(
        v03.x(), v13.x(), v23.x(),
        v03.y(), v13.y(), v23.y(),
        v03.z(), v13.z(), v23.z() );

    return M.inverted() * ( global - v3 );
}
开发者ID:naohisas,项目名称:KVS,代码行数:15,代码来源:TetrahedralCell.cpp


示例20: switch

/*===========================================================================*/
bool StreamlineBase::check_for_inside_volume( const kvs::Vec3& point )
{
    switch ( BaseClass::volume()->volumeType() )
    {
    case kvs::VolumeObjectBase::Structured:
    {
        const kvs::StructuredVolumeObject* structured_volume =
            kvs::StructuredVolumeObject::DownCast( BaseClass::volume() );
        switch ( structured_volume->gridType() )
        {
        case kvs::StructuredVolumeObject::Uniform:
        {
            const float dimx = static_cast<float>( structured_volume->resolution().x() - 1 );
            const float dimy = static_cast<float>( structured_volume->resolution().y() - 1 );
            const float dimz = static_cast<float>( structured_volume->resolution().z() - 1 );

            if ( point.x() < 0.0f || dimx < point.x() ) return false;
            if ( point.y() < 0.0f || dimy < point.y() ) return false;
            if ( point.z() < 0.0f || dimz < point.z() ) return false;

            return true;
        }
        case kvs::StructuredVolumeObject::Rectilinear:
        {
            const kvs::Vec3& min_obj = structured_volume->minObjectCoord();
            const kvs::Vec3& max_obj = structured_volume->maxObjectCoord();

            if ( point.x() < min_obj.x() || max_obj.x() < point.x() ) return false;
            if ( point.y() < min_obj.y() || max_obj.y() < point.y() ) return false;
            if ( point.z() < min_obj.z() || max_obj.z() < point.z() ) return false;

            return true;
        }
        default: break;
        }
        break;
    }
    default: break;
    }

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ kvs::Vector3f类代码示例发布时间:2022-05-31
下一篇:
C++ kurlgoogleprivate::Replacements类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap