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


C++ ON_Xform类代码示例

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


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

示例1: ON_GL

void ON_GL( ON_Viewport& viewport,
            int port_left, int port_right,
            int port_bottom, int port_top
          )
{
  // Sets viewport's port to port_* values and adjusts frustum
  // so it's aspect matches the port's.
  ON_Xform projectionMatrix; // camera to clip transformation

  const int port_width  = abs(port_right - port_left);
  const int port_height = abs(port_top - port_bottom);
  if ( port_width == 0 || port_height == 0 )
    return;
  const double port_aspect = ((double)port_width)/((double)port_height);

  viewport.SetFrustumAspect( port_aspect );

  viewport.SetScreenPort( port_left, port_right, port_bottom, port_top,
                          0, 0xff );

  ON_BOOL32 bHaveCameraToClip = viewport.GetXform( 
                                       ON::camera_cs,  
                                       ON::clip_cs,
                                       projectionMatrix 
                                       );

  if ( bHaveCameraToClip ) {
    projectionMatrix.Transpose();
    glMatrixMode(GL_PROJECTION);
    glLoadMatrixd( &projectionMatrix.m_xform[0][0] );
  }
}
开发者ID:Bardo91,项目名称:pcl,代码行数:32,代码来源:opennurbs_gl.cpp

示例2: CalculateTransform

BOOL COrientOnCrvXform::CalculateTransform( CRhinoViewport& vp, const ON_3dPoint& pt, ON_Xform& xform )
{
  BOOL bResult = FALSE;

  if( m_path_curve )
  {
    double t = 0.0;
    if( m_path_curve->GetClosestPoint(pt, &t) )
    {
      ON_3dPoint origin = m_path_curve->PointAt( t );
      ON_Plane dest_plane;
      if( m_perp_mode )
      {
        ON_3dVector tangent = m_path_curve->TangentAt( t );
        MakeNormalPlane( origin, tangent, dest_plane );
      }
      else
      {
        dest_plane.origin = origin;
        dest_plane.xaxis = m_path_curve->TangentAt( t );
        dest_plane.zaxis = m_base_plane.zaxis;
        dest_plane.yaxis = ON_CrossProduct( dest_plane.zaxis, dest_plane.xaxis );
        dest_plane.UpdateEquation();
      }
      xform.Rotation( m_base_plane, dest_plane );
      bResult = xform.IsValid() ? TRUE : FALSE;
    }
  }

  return bResult;
}
开发者ID:619486,项目名称:Rhino5Samples_CPP,代码行数:31,代码来源:cmdSampleOrientOnCrv.cpp

示例3: Scale

ON_BOOL32 ON_Geometry::Scale( double x )
{
  if ( x == 1.0 )
    return true;
  ON_Xform s;
  s.Scale( x, x, x );
  return Transform( s );
}
开发者ID:ckvk,项目名称:opennurbs,代码行数:8,代码来源:opennurbs_geometry.cpp

示例4: Translate

ON_BOOL32 ON_Geometry::Translate( const ON_3dVector& delta )
{
  if ( delta.IsZero() )
    return true;
  ON_Xform tr;
  tr.Translation( delta );
  return Transform( tr );
}
开发者ID:ckvk,项目名称:opennurbs,代码行数:8,代码来源:opennurbs_geometry.cpp

示例5: Translate

bool ON_Plane::Translate(
      const ON_3dVector& delta
      )
{
  ON_Xform tr;
  tr.Translation( delta );
  return Transform( tr );
}
开发者ID:jl2,项目名称:ONView,代码行数:8,代码来源:opennurbs_plane.cpp

示例6: sin

bool ON_BezierCage::Rotate(
      double sin_angle,          // sin(angle)
      double cos_angle,          // cos(angle)
      const ON_3dVector& axis, // axis of rotation
      const ON_3dPoint& center // center of rotation
      )
{
  ON_Xform rot;
  rot.Rotation( sin_angle, cos_angle, axis, center );
  return Transform( rot );
}
开发者ID:raazui,项目名称:3D-Surface-Reconstruction,代码行数:11,代码来源:opennurbs_beziervolume.cpp

示例7: GetRotation

bool ON_Quaternion::GetRotation(ON_Xform& xform) const
{
  ON_Plane plane;
  bool rc = GetRotation(plane);
  if (rc)
    xform.Rotation(ON_Plane::World_xy,plane);
  else if (IsZero())
    xform.Zero();
  else
    xform.Identity();
  return rc;
}
开发者ID:Alpha-Kand,项目名称:qcad,代码行数:12,代码来源:opennurbs_quaternion.cpp

示例8: q

bool ON_Quaternion::GetRotation(ON_Xform& xform) const
{
  bool rc;
  ON_Quaternion q(*this);
  if ( q.Unitize() )
  {
    if (    fabs(q.a-a) <= ON_ZERO_TOLERANCE
         && fabs(q.b-b) <= ON_ZERO_TOLERANCE
         && fabs(q.c-c) <= ON_ZERO_TOLERANCE
         && fabs(q.d-d) <= ON_ZERO_TOLERANCE
         )
    {
      // "this" was already unitized - don't tweak bits
      q = *this;
    }
    xform[1][0] = 2.0*(q.b*q.c + q.a*q.d);
    xform[2][0] = 2.0*(q.b*q.d - q.a*q.c);
    xform[3][0] = 0.0;

    xform[0][1] = 2.0*(q.b*q.c - q.a*q.d);
    xform[2][1] = 2.0*(q.c*q.d + q.a*q.b);
    xform[3][1] = 0.0;

    xform[0][2] = 2.0*(q.b*q.d + q.a*q.c);
    xform[1][2] = 2.0*(q.c*q.d - q.a*q.b);
    xform[3][2] = 0.0;

    q.b = q.b*q.b;
    q.c = q.c*q.c;
    q.d = q.d*q.d;
    xform[0][0] = 1.0 - 2.0*(q.c + q.d);
    xform[1][1] = 1.0 - 2.0*(q.b + q.d);
    xform[2][2] = 1.0 - 2.0*(q.b + q.c);

    xform[0][3] = xform[1][3] = xform[2][3] = 0.0;
    xform[3][3] = 1.0;
    rc = true;
  }
  else if ( IsZero() )
  {
    xform.Zero();
    rc = false;
  }
  else
  {
    // something is seriously wrong
    ON_ERROR("ON_Quaternion::GetRotation(ON_Xform) quaternion is invalid");
    xform.Identity();
    rc = false;
  }

  return rc;
}
开发者ID:raazui,项目名称:3D-Surface-Reconstruction,代码行数:53,代码来源:opennurbs_quaternion.cpp

示例9: sin

ON_BOOL32 ON_Geometry::Rotate(
      double sin_angle,          // sin(angle)
      double cos_angle,          // cos(angle)
      const ON_3dVector& axis, // axis of rotation
      const ON_3dPoint& center // center of rotation
      )
{
  if ( sin_angle == 0.0 && cos_angle == 1.0 )
    return true;
  ON_Xform rot;
  rot.Rotation( sin_angle, cos_angle, axis, center );
  return Transform( rot );
}
开发者ID:ckvk,项目名称:opennurbs,代码行数:13,代码来源:opennurbs_geometry.cpp

示例10: tmp

BOOL ON_Hatch::Transform( const ON_Xform& xform)
{
  if( fabs( fabs( xform.Determinant()) - 1.0) > 1.0e-4)
  {
    // xform has a scale component
    ON_Plane tmp( m_plane);
    tmp.Transform( xform);
    ON_Xform A, B, T;
    A.Rotation( ON_xy_plane, m_plane);
    B.Rotation( tmp, ON_xy_plane);
    T = B * xform * A;

    // kill translation and z-scaling
    T[0][2] = T[0][3] = 0.0;
    T[1][2] = T[1][3] = 0.0;
    T[2][0] = T[2][1] = 0.0; T[2][2] = 1.0; T[2][3] = 0.0;
    T[3][0] = T[3][1] = T[3][2] = 0.0; T[3][3] = 1.0;

    for( int i = 0; i < LoopCount(); i++)
      m_loops[i]->m_p2dCurve->Transform( T);
  }
  int rc = m_plane.Transform( xform);

  return rc;
}
开发者ID:cciechad,项目名称:brlcad,代码行数:25,代码来源:opennurbs_hatch.cpp

示例11: TransformUserData

ON_BOOL32
ON_PlaneSurface::Transform( const ON_Xform& xform )
{
  TransformUserData(xform);
  ON_3dPoint p = m_plane.origin + m_extents[0][0]*m_plane.xaxis + m_extents[1][0]*m_plane.yaxis;
  ON_3dPoint q = m_plane.origin + m_extents[0][1]*m_plane.xaxis + m_extents[1][1]*m_plane.yaxis;
  bool rc = m_plane.Transform( xform )?true:false;
  if (rc && fabs(fabs(xform.Determinant())-1.0) > ON_SQRT_EPSILON )
  {
    p = xform*p;
    q = xform*q;
    double x0, x1, y0, y1;
    rc = false;
    if ( m_plane.ClosestPointTo(p,&x0,&y0) && m_plane.ClosestPointTo(q,&x1,&y1) )
    {
      if ( x0 < x1 && y0 < y1 )
      {
        m_extents[0].Set(x0,x1);
        m_extents[1].Set(y0,y1);
        rc = true;
      }
    }
  }
  return rc;
}
开发者ID:2php,项目名称:pcl,代码行数:25,代码来源:opennurbs_planesurface.cpp

示例12: sin

// rotate line about a point and axis
bool ON_Line::Rotate(
      double sin_angle,                  // sin(angle)
      double cos_angle,                  // cos(angle)
      const ON_3dVector& axis,  // axis of rotation
      const ON_3dPoint& center  // center of rotation
      )
{
  ON_Xform rot;
  rot.Rotation( sin_angle, cos_angle, axis, center );
  const bool bFixP0 = (from==center);
  const bool bFixP1 = (to==center);
  const bool rc = Transform( rot );
  if ( bFixP0 )
    from = center;
  if ( bFixP1 )
    to = center;
  return rc;
}
开发者ID:ckvk,项目名称:opennurbs,代码行数:19,代码来源:opennurbs_line.cpp

示例13: IsValid

ON_BOOL32 ON_InstanceRef::IsValid( ON_TextLog* text_log ) const
{
  if ( 0 == ON_UuidCompare( m_instance_definition_uuid, ON_nil_uuid) )
  {
    if ( text_log )
      text_log->Print("ON_InstanceRef has nil m_instance_definition_uuid.\n");
    return false;
  }

  ON_Xform tmp = m_xform.Inverse()*m_xform;
  if ( !tmp.IsIdentity( ON_InstanceRef::m_singular_xform_tol ) )
  {
    if ( text_log )
      text_log->Print("ON_InstanceRef has singular m_xform.\n");
    return false;
  }
  return true;
}
开发者ID:jl2,项目名称:ONView,代码行数:18,代码来源:opennurbs_instance.cpp

示例14: Mat4Dto4F

void CRhGLShaderProgram::SetupViewport(const ON_Viewport& vp)
{
  ON_Xform  mv;
  bool      bHaveModeView = false;
  
  if ( m_Uniforms.rglModelViewProjectionMatrix >= 0 )
  {
    float    ModelViewProjection[16];
    ON_Xform mvp;
    
    vp.GetXform( ON::world_cs, ON::clip_cs, mvp );
    mvp.Transpose();
    
    Mat4Dto4F( &mvp.m_xform[0][0], ModelViewProjection );
    glUniformMatrix4fv( m_Uniforms.rglModelViewProjectionMatrix, 1, GL_FALSE, ModelViewProjection );
  }
    
  if ( m_Uniforms.rglModelViewMatrix >= 0 )
  {
    float  ModelView[16];
    
    vp.GetXform( ON::world_cs, ON::camera_cs, mv );
    mv.Transpose();
    bHaveModeView = true;
    
    Mat4Dto4F( &mv.m_xform[0][0], ModelView );
    glUniformMatrix4fv( m_Uniforms.rglModelViewMatrix, 1, GL_FALSE, ModelView );
  }

  if ( m_Uniforms.rglProjectionMatrix >= 0 )
  {
    float     Projection[16];
    ON_Xform  pr;
  
    vp.GetXform( ON::camera_cs, ON::clip_cs,  pr );
    pr.Transpose();
 
    Mat4Dto4F( &pr.m_xform[0][0], Projection );
    glUniformMatrix4fv( m_Uniforms.rglProjectionMatrix, 1, GL_FALSE, Projection );
  }
 
  if ( m_Uniforms.rglNormalMatrix >= 0 )
  {
    float    NormalMatrix[9];
    
    if ( !bHaveModeView )
    {
      vp.GetXform( ON::world_cs, ON::camera_cs, mv );
      mv.Transpose();
      bHaveModeView = true;
    }
    
    Mat4Dto3F( &mv.m_xform[0][0], NormalMatrix );
    glUniformMatrix3fv( m_Uniforms.rglNormalMatrix, 1, GL_FALSE, NormalMatrix );
  }
}
开发者ID:UIKit0,项目名称:rhinoviewer,代码行数:56,代码来源:RhGLShaderProgram.cpp

示例15: Transform

bool ON_3dPointArray::Rotate(
      double sin_angle,
      double cos_angle,
      const ON_3dVector& axis_of_rotation,
      const ON_3dPoint& center_of_rotation
      )
{
  const int count = m_count;
  ON_Xform rot;
  rot.Rotation( sin_angle, cos_angle, axis_of_rotation, center_of_rotation );
  ON_SimpleArray<int> fix_index(128);
  int i;
  for ( i = 0; i < count; i++ ) {
    if ( m_a[i] == center_of_rotation )
      fix_index.Append(i);
  }
  const bool rc = Transform( rot );
  for ( i = 0; i < fix_index.Count(); i++ ) {
    m_a[fix_index[i]] = center_of_rotation;
  }
  return rc;
}
开发者ID:Bastl34,项目名称:PCL,代码行数:22,代码来源:opennurbs_array.cpp


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