Ejemplo n.º 1
0
void Triangle::find_triangle_dominant_axis()
{
    DBL x, y, z;

    x = fabs(Normal_Vector[X]);
    y = fabs(Normal_Vector[Y]);
    z = fabs(Normal_Vector[Z]);

    Dominant_Axis = max3_coordinate(x, y, z);
}
Ejemplo n.º 2
0
static void find_triangle_dominant_axis(TRIANGLE *Triangle)
{
  DBL x, y, z;

  x = fabs(Triangle->Normal_Vector[X]);
  y = fabs(Triangle->Normal_Vector[Y]);
  z = fabs(Triangle->Normal_Vector[Z]);

  Triangle->Dominant_Axis = max3_coordinate(x, y, z);
}
Ejemplo n.º 3
0
static int compute_smooth_triangle(SMOOTH_TRIANGLE *Triangle)
{
  VECTOR P3MinusP2, VTemp1, VTemp2;
  DBL x, y, z, uDenominator, Proj;

  VSub(P3MinusP2, Triangle->P3, Triangle->P2);

  x = fabs(P3MinusP2[X]);
  y = fabs(P3MinusP2[Y]);
  z = fabs(P3MinusP2[Z]);

  Triangle->vAxis = max3_coordinate(x, y, z);

  VSub(VTemp1, Triangle->P2, Triangle->P3);

  VNormalize(VTemp1, VTemp1);

  VSub(VTemp2, Triangle->P1, Triangle->P3);

  VDot(Proj, VTemp2, VTemp1);

  VScaleEq(VTemp1, Proj);

  VSub(Triangle->Perp, VTemp1, VTemp2);

  VNormalize(Triangle->Perp, Triangle->Perp);

  VDot(uDenominator, VTemp2, Triangle->Perp);

  VInverseScaleEq(Triangle->Perp, -uDenominator);
  
  /* Degenerate if smooth normals are more than 90 from actual normal
     or its inverse. */
  VDot(x,Triangle->Normal_Vector,Triangle->N1);
  VDot(y,Triangle->Normal_Vector,Triangle->N2);
  VDot(z,Triangle->Normal_Vector,Triangle->N3);
  if ( ((x<0.0) && (y<0.0) && (z<0.0)) ||
       ((x>0.0) && (y>0.0) && (z>0.0)) )
  {
    return(true);
  }
  Set_Flag(Triangle, DEGENERATE_FLAG);
  return(false);
}
Ejemplo n.º 4
0
bool SmoothTriangle::Compute_Smooth_Triangle()
{
    Vector3d P3MinusP2, VTemp1, VTemp2;
    DBL x, y, z, uDenominator, Proj;

    P3MinusP2 = P3 - P2;

    x = fabs(P3MinusP2[X]);
    y = fabs(P3MinusP2[Y]);
    z = fabs(P3MinusP2[Z]);

    vAxis = max3_coordinate(x, y, z);

    VTemp1 = (P2 - P3).normalized();

    VTemp2 = (P1 - P3);

    Proj = dot(VTemp2, VTemp1);

    VTemp1 *= Proj;

    Perp = (VTemp1 - VTemp2).normalized();

    uDenominator = dot(VTemp2, Perp);

    Perp /= -uDenominator;

    /* Degenerate if smooth normals are more than 90 from actual normal
       or its inverse. */
    x = dot(Normal_Vector,N1);
    y = dot(Normal_Vector,N2);
    z = dot(Normal_Vector,N3);
    if ( ((x<0.0) && (y<0.0) && (z<0.0)) ||
         ((x>0.0) && (y>0.0) && (z>0.0)) )
    {
        return(true);
    }
    Set_Flag(this, DEGENERATE_FLAG);
    return(false);
}