コード例 #1
0
ファイル: opennurbs_arc.cpp プロジェクト: Bastl34/PCL
bool ON_Arc::Create( // arc is parallel to XY plane
  const ON_3dPoint& center, // center
  double r,            // radius
  double angle_radians // angle in radians
  )
{
  ON_Plane p;
  p.CreateFromNormal( center, ON_zaxis );
  return Create( ON_Circle(p,r), ON_Interval( 0.0, angle_radians ) );
}
コード例 #2
0
ファイル: opennurbs_plane.cpp プロジェクト: jl2/ONView
bool ON_Plane::Morph( const ON_SpaceMorph& morph )
{
  ON_Plane mp;
  double s = sqrt( fabs(origin.MaximumCoordinate())*ON_SQRT_EPSILON + ON_ZERO_TOLERANCE );
  mp.xaxis = morph.MorphVector(origin,s*xaxis);
  mp.yaxis = morph.MorphVector(origin,s*yaxis);
  mp.zaxis = morph.MorphVector(origin,s*zaxis);
  origin = morph.MorphPoint(origin);
  UpdateEquation();
  bool bx = mp.xaxis.Unitize();
  bool by = mp.yaxis.Unitize();
  bool bz = mp.zaxis.Unitize();
  if (!bx)
  {
    mp.xaxis = ON_CrossProduct(mp.yaxis,mp.zaxis);
    bx = mp.xaxis.Unitize();
  }
  if (!by)
  {
    mp.yaxis = ON_CrossProduct(mp.zaxis,mp.xaxis);
    by = mp.yaxis.Unitize();
  }
  if (!bz)
  {
    mp.zaxis = ON_CrossProduct(mp.xaxis,mp.yaxis);
    bz = mp.zaxis.Unitize();
  }

  mp.origin.Set(0.0,0.0,0.0);
  mp.UpdateEquation();
  bool rc = mp.IsValid();
  ON_3dVector x, y, z;
  if ( rc )
  {
    x = mp.xaxis;
    y = mp.yaxis;
    z = mp.zaxis;
  }
  else
  {
    x = ON_CrossProduct(mp.yaxis,mp.zaxis);
    y = ON_CrossProduct(mp.zaxis,mp.xaxis);
    z = ON_CrossProduct(mp.xaxis,mp.yaxis);
    x.Unitize();
    y.Unitize();
    z.Unitize();
    x = mp.xaxis + x;
    y = mp.yaxis + y;
    z = mp.zaxis + z;
    x.Unitize();
    y.Unitize();
    z.Unitize();
    rc = mp.CreateFromFrame(ON_origin,x,y);
    if (rc)
    {
      x = mp.xaxis;
      y = mp.yaxis;
      z = mp.zaxis;
    }
    else
    {
      rc = mp.CreateFromFrame(ON_origin,y,z);
      if ( rc )
      {
        y = mp.xaxis;
        z = mp.yaxis;
        x = mp.zaxis;
      }
      else
      {
        rc = mp.CreateFromFrame(ON_origin,z,x);
        if (rc)
        {
          z = mp.xaxis;
          x = mp.yaxis;
          y = mp.zaxis;
        }
        else
        {
          rc = mp.CreateFromNormal(ON_origin,z);
          if (rc)
          {
            x = mp.xaxis;
            y = mp.yaxis;
            z = mp.zaxis;
          }
        }
      }
    }
  }

  if (rc)
  {
    xaxis = x;
    yaxis = y;
    zaxis = z;
    UpdateEquation();
  }

  return rc;
}