Пример #1
0
double VerdictVector::distance_between(const VerdictVector& test_vector)
{
    double xv = xVal - test_vector.x();
    double yv = yVal - test_vector.y();
    double zv = zVal - test_vector.z();

    return( sqrt( xv * xv + yv * yv + zv * zv ) );
}
Пример #2
0
/*!
  The scaled jacobian of a tri

  minimum of the jacobian divided by the lengths of 2 edge vectors
*/
C_FUNC_DEF double v_tri_scaled_jacobian( int /*num_nodes*/, double coordinates[][3])
{
  static const double detw = 2./sqrt(3.0);
  VerdictVector first, second;
  double jacobian; 
  
  VerdictVector edge[3];
  edge[0].set(coordinates[1][0] - coordinates[0][0],
              coordinates[1][1] - coordinates[0][1],
              coordinates[1][2] - coordinates[0][2]);

  edge[1].set(coordinates[2][0] - coordinates[0][0],
              coordinates[2][1] - coordinates[0][1],
              coordinates[2][2] - coordinates[0][2]);

  edge[2].set(coordinates[2][0] - coordinates[1][0],
              coordinates[2][1] - coordinates[1][1],
              coordinates[2][2] - coordinates[1][2]);
  first = edge[1]-edge[0];
  second = edge[2]-edge[0];

  VerdictVector cross = first * second;
  jacobian = cross.length();

  double max_edge_length_product;
  max_edge_length_product = VERDICT_MAX( edge[0].length()*edge[1].length(),
                            VERDICT_MAX( edge[1].length()*edge[2].length(), 
                                         edge[0].length()*edge[2].length() ) ); 

  if( max_edge_length_product < VERDICT_DBL_MIN )
    return (double)0.0;

  jacobian *= detw;
  jacobian /= max_edge_length_product; 

  if( compute_normal )
  {
    //center of tri
    double point[3], surf_normal[3];
    point[0] =  (coordinates[0][0] + coordinates[1][0] + coordinates[2][0]) / 3;
    point[1] =  (coordinates[0][1] + coordinates[1][1] + coordinates[2][1]) / 3;
    point[2] =  (coordinates[0][2] + coordinates[1][2] + coordinates[2][2]) / 3;

    //dot product
    compute_normal( point, surf_normal ); 
    if( (cross.x()*surf_normal[0] + 
         cross.y()*surf_normal[1] +
         cross.z()*surf_normal[2] ) < 0 )
      jacobian *= -1; 
  }

  if( jacobian > 0 )
    return (double) VERDICT_MIN( jacobian, VERDICT_DBL_MAX );
  return (double) VERDICT_MAX( jacobian, -VERDICT_DBL_MAX );

}
Пример #3
0
inline void product( VerdictVector& a1,
                     VerdictVector& a2,
                     VerdictVector& a3,
                     VerdictVector& b1,
                     VerdictVector& b2,
                     VerdictVector& b3,
                     VerdictVector& c1,
                     VerdictVector& c2,
                     VerdictVector& c3 )
{

    VerdictVector x1, x2, x3;

    x1.set( a1.x(), a2.x(), a3.x() );
    x2.set( a1.y(), a2.y(), a3.y() );
    x3.set( a1.z(), a2.z(), a3.z() );

    c1.set( x1 % b1, x2 % b1, x3 % b1 );
    c2.set( x1 % b2, x2 % b2, x3 % b2 );
    c3.set( x1 % b3, x2 % b3, x3 % b3 );
}
Пример #4
0
//- Find next point from this point using a direction and distance
void VerdictVector::next_point( const VerdictVector &direction,
                                double distance, VerdictVector& out_point )
{
    VerdictVector my_direction = direction;
    my_direction.normalize();

    // Determine next point in space
    out_point.x( xVal + (distance * my_direction.x()) );
    out_point.y( yVal + (distance * my_direction.y()) );
    out_point.z( zVal + (distance * my_direction.z()) );

    return;
}
Пример #5
0
bool VerdictVector::within_tolerance( const VerdictVector &vectorPtr2,
                                      double tolerance) const
{
    if (( fabs (this->x() - vectorPtr2.x()) < tolerance) &&
            ( fabs (this->y() - vectorPtr2.y()) < tolerance) &&
            ( fabs (this->z() - vectorPtr2.z()) < tolerance)
       )
    {
        return true;
    }

    return false;
}
Пример #6
0
inline void inverse(VerdictVector x1,
                    VerdictVector x2,
                    VerdictVector x3,
                    VerdictVector& u1,
                    VerdictVector& u2,
                    VerdictVector& u3 )
{
    double  detx = v_determinant(x1, x2, x3);
    VerdictVector rx1, rx2, rx3;

    rx1.set(x1.x(), x2.x(), x3.x());
    rx2.set(x1.y(), x2.y(), x3.y());
    rx3.set(x1.z(), x2.z(), x3.z());

    u1 = rx2 * rx3;
    u2 = rx3 * rx1;
    u3 = rx1 * rx2;

    u1 /= detx;
    u2 /= detx;
    u3 /= detx;
}